View unanswered posts | View active topics It is currently 20 Oct 2014 18:30



Post new topic Reply to topic  [ 9 posts ] 
rename all files excep today files and transfer over network 
Author Message

Joined: 10 May 2012 01:29
Posts: 5
Post 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


10 May 2012 04:37
Profile
Online

Joined: 10 Feb 2012 02:20
Posts: 4307
Post Re: rename all files excep today files and transfer over net
This will rename the *most recent* .csv file in the folder.

Code:
@echo off
for /f "delims=" %%a in ('dir *.csv /b /od') do set "file=%%a"
ren "%file%" "416_%file%"


10 May 2012 05:31
Profile
Online

Joined: 10 Feb 2012 02:20
Posts: 4307
Post 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?


10 May 2012 05:35
Profile

Joined: 10 May 2012 01:29
Posts: 5
Post Re: rename all files excep today files and transfer over net
Yes i don't want to rename file created or generated today


11 May 2012 00:26
Profile

Joined: 10 May 2012 01:29
Posts: 5
Post 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)


11 May 2012 00:29
Profile
Online

Joined: 10 Feb 2012 02:20
Posts: 4307
Post 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.

Quote:
@echo off
for /f "skip=1 delims=" %%a in ('dir *.csv /a-d /b /o:-d') do ren "%%a" "416_%%a"


11 May 2012 01:07
Profile

Joined: 10 May 2012 01:29
Posts: 5
Post 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


11 May 2012 02:07
Profile

Joined: 23 Dec 2011 13:59
Posts: 1928
Post 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.


11 May 2012 06:17
Profile

Joined: 10 May 2012 01:29
Posts: 5
Post Re: rename all files excep today files and transfer over net
Thank you very much


11 May 2012 06:35
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.