PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > Script to parse programatically through files in a folder
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Script to parse programatically through files in a folder

Réponse
 
LinkBack Outils de la discussion
Vieux 17/11/2007, 21h56   #1
Hassan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Script to parse programatically through files in a folder

I am new to scripting and even programming for that matter..

What i want to do is run a command that processes all files in a folder and
once successfully done move the processed file to another folder

So for eg:

Right now, i want to run this

C:\command1.exe c:\folder1\file1.txt

My folder1 contants many files in it such as file1.txt,file2.txt,etc.. And i
want to process all these files. It would appear that these file names are
passed as parameters to that command file command1.exe

Once I process file1 successfully, I want to move it to c:\successfularchive

Can you provide a template for me to use ? I would so appreciate it.

Thanks



  Réponse avec citation
Vieux 18/11/2007, 13h06   #2
Michael Bednarek
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to parse programatically through files in a folder

On Sat, 17 Nov 2007 12:56:58 -0800, Hassan wrote in
microsoft.public.windows.server.scripting:

>I am new to scripting and even programming for that matter..
>
>What i want to do is run a command that processes all files in a folder and
>once successfully done move the processed file to another folder
>
>So for eg:
>
>Right now, i want to run this
>
>C:\command1.exe c:\folder1\file1.txt
>
>My folder1 contants many files in it such as file1.txt,file2.txt,etc.. And i
>want to process all these files. It would appear that these file names are
>passed as parameters to that command file command1.exe
>
>Once I process file1 successfully, I want to move it to c:\successfularchive
>
>Can you provide a template for me to use ? I would so appreciate it.


Look at the output of FOR /? from cmd.exe, or type this in your
Start/Run box: ms-its:%WINDIR%\\ntcmds.chm::/for.htm

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
  Réponse avec citation
Vieux 19/11/2007, 04h44   #3
Al Dunbar
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to parse programatically through files in a folder


"Michael Bednarek" <mbATmbednarek.com@BLACKHOLESPAM.NET> wrote in message
news:6fa0k3drphabf9boqajouud0cfsk92ufui@4ax.com...
> On Sat, 17 Nov 2007 12:56:58 -0800, Hassan wrote in
> microsoft.public.windows.server.scripting:
>
>>I am new to scripting and even programming for that matter..
>>
>>What i want to do is run a command that processes all files in a folder
>>and
>>once successfully done move the processed file to another folder
>>
>>So for eg:
>>
>>Right now, i want to run this
>>
>>C:\command1.exe c:\folder1\file1.txt
>>
>>My folder1 contants many files in it such as file1.txt,file2.txt,etc.. And
>>i
>>want to process all these files. It would appear that these file names are
>>passed as parameters to that command file command1.exe
>>
>>Once I process file1 successfully, I want to move it to
>>c:\successfularchive
>>
>>Can you provide a template for me to use ? I would so appreciate it.

>
> Look at the output of FOR /? from cmd.exe, or type this in your
> Start/Run box: ms-its:%WINDIR%\\ntcmds.chm::/for.htm


The only issue I see here is how to determine that each file processed was
processed *successfully*. Perhaps the .exe will indicate failure with a
non-zero return code. Or perhaps it creates an error log file to put error
messages in if something went wrong. Anyway, assuming the non-zero error
code, try something like this in a batch file:

setlocal enabledelayedexpansion
for %%F in (C:\folder1\*.txt) do (
C:\command1.exe %%F
if errorlevel 1 (
echo/error encountered on file %%F & pause
) else (
move %%F C:\successfularchive
)
)

/Al


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h33.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11496 seconds with 11 queries