rename all files excep today files and transfer over network
Moderator: DosItHelp
rename all files excep today files and transfer over network
i hv a folder call c:\data\ in which every day (12 am to 1 am) one files generate with file name 20120510.csv (yyyymmdd.csv) each file updated till (12 am morning. after that i rename file with a code like 416 as 416_20120510.csv and then transfer over network . My problem is there are many files in folder like 20120509.csv etc... My problem is not rename today's file created except this all files are rename with a code 416_yyyymmdd.csv
Kindly help me
Kindly help me
Re: rename all files excep today files and transfer over net
This will rename the *most recent* .csv file in the folder.
Code: Select all
@echo off
for /f "delims=" %%a in ('dir *.csv /b /od') do set "file=%%a"
ren "%file%" "416_%file%"
Re: rename all files excep today files and transfer over net
I think misunderstood your English.
Is there one file created with todays date that you do not want to have renamed?
Or are there more files with todays date?
Is there one file created with todays date that you do not want to have renamed?
Or are there more files with todays date?
Re: rename all files excep today files and transfer over net
Yes i don't want to rename file created or generated today
Re: rename all files excep today files and transfer over net
i.e in folder there are many files like including today file (i.e 20120511.csv and old dated file like 20120510.csv, 20120509.csv etc...) so i want to rename excluding today file (i.e 20120511.csv)
Re: rename all files excep today files and transfer over net
It's easy to do without testing for date if there is only one file every day.
This will skip the newest file in the folder and rename the rest.
This will skip the newest file in the folder and rename the rest.
@echo off
for /f "skip=1 delims=" %%a in ('dir *.csv /a-d /b /o:-d') do ren "%%a" "416_%%a"
Re: rename all files excep today files and transfer over net
Thanks but my all files are in c:\data\ so where i have to mention the directory path in batch file
Re: rename all files excep today files and transfer over net
priya171 wrote:Thanks but my all files are in c:\data\ so where i have to mention the directory path in batch file
If you put the batch file in C:\data you don't have to put the path in the batch file.
If you really want to put it in there then add it to the DIR command.
Re: rename all files excep today files and transfer over net
Thank you very much