Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All Can anyone help me with this?
How do I use the TimeStamp Now() for the csv files that is migrated to new folder (TestFolder1)?
BatFile:
Load
'REM This is a batch file test' As [@echo off]
AutoGenerate(1);
Let x = Timestamp(Now(),'YYYY-MM-DD hh.mm.ss')
For Each vFile in FileList('C:\Users\Documents\TestFolder\*.csv')
BatFile:
Load
'MOVE $(vFile) C:\Users\Documents\TestFolder1 ' As [@echo off]
AutoGenerate(1);
Next
Store BatFile into 'C:\Users\Documents\test'.bat (txt);
Drop Table BatFile;
EXECUTE C:\Users\Documents\test.bat;
Thanks
try with a small change in the for loop
DIRECTORY;
BatFile:
Load
'REM This is a batch file test' As [@echo off]
AutoGenerate(1);
Let x = Date(Today(),'YYYYMMDD');
For Each vFile in FileList('*.csv')
BatFile:
FIRST 1 Load
'MOVE $(vFile) .\NewFolder\$(x)' & SubField('$(vFile)', '\', -1) As [@echo off]
AutoGenerate(1);
Next
Store BatFile into 'test'.bat (txt);
Drop Table BatFile;
EXECUTE test.bat;
What are you trying to do?
Hi Gysbert,
Thanks for your reply.
What i am trying to do is, Moving csv files from one folder to another folder with the today's date attched to the csv files name.
For eaxmple,
If i have two csv files in folder: C:\Users\Documents\TestFolder
1. ABC.csv
2. XYZ.csv
And i want to move this two csv files to : C:\Users\Documents\TestFolder1
with names like,
1. 20160822ABC.csv
2. 20160822XYZ.csv
Thanks,
Sk
Why not just use Timstamp() or Today()? Timestamp(Now()) uses a lot of resources.
Thanks for the reply. But i just cant get the script to work the way i want it to be. I can move the file but cant add the datestamp to the file name when they are moved in the new file location.
Thanks,
Sk
If your file names don't ever contain spaces you can try this:
BatFile:
Load
'REM This is a batch file test' As [@echo off]
AutoGenerate(1);
Let x = Date(Today(),'YYYY-MM-DD');
For Each vFile in FileList('C:\Users\Documents\TestFolder\*.csv')
BatFile:
FIRST 1 Load
'MOVE $(vFile) C:\Users\Documents\TestFolder1\$(x)' & FileName() As [@echo off]
FROM $(vFile) (txt);
Next
Store BatFile into 'C:\Users\Documents\test'.bat (txt);
Drop Table BatFile;
EXECUTE C:\Users\Documents\test.bat;
Hi Gysbert,
Thanks for your reply. The script is not pulling the File name with the Date stamp. Rather i am geting one text file with the Date stamp on it. No matter how many csv files are there its only making one text file with the datestamp with no file name from the original folder.
Thanks,
Sk
HI Sk,
Give the MOVE string some quotations and it will move with the rename:
MOVE "C:\Folder\MOVE2\TEST.csv" "C:\Folder\MOVE\TEST123.csv"
Charlie
try with a small change in the for loop
DIRECTORY;
BatFile:
Load
'REM This is a batch file test' As [@echo off]
AutoGenerate(1);
Let x = Date(Today(),'YYYYMMDD');
For Each vFile in FileList('*.csv')
BatFile:
FIRST 1 Load
'MOVE $(vFile) .\NewFolder\$(x)' & SubField('$(vFile)', '\', -1) As [@echo off]
AutoGenerate(1);
Next
Store BatFile into 'test'.bat (txt);
Drop Table BatFile;
EXECUTE test.bat;