Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch script move files to folder named after date 1

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
I have the following

Code:
cmd.exe /C MD "%DATE:/=-%%TIME::=.%"

for %%B IN (C:\battest\*.vbs) do call %%B

where I am stuck is after i have executed my vbs file i want to move it to the folder i have created just above, I cant see how i can reference this in the for next



Chance,

F, G + 3MSTG
 
You couldn't specify that in the for loop unless you called another batch file in the loop, which executes the vbs and then copies the file to the specified location. But what's stopping you from putting a copy *.vbs line in the last line of your batch file?
 
This folder would contain several VBS files

The files are created by a application throughout the day. then the batch script is being scheduled to run every fifteen minutes to pick up this folder execute the VBS files in the folder and then move them to a folder with the date and time stamp



Chance,

F, G + 3MSTG
 
I'd call a separate batch file in your for loop which would contain two lines. One to execute the vbs, another to move the vbs after it is done executing. You can feed a batch file a variable like so:

filename.bat computer

"computer" would be the first variable within the batch file. In your for loop, you'd just specify:

filename.bat %%B

The contents of filename.bat would be something like:

cscript %1
ping -n 1 127.0.0.1 (for a pause in the script)
copy %1 c:\blah blah blah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top