Read the file and replace its filename with current date
Question 1:
开发者_开发问答I wanna append a list of filenames with a sequence no. at the back to current date , e.g.
Originally:
ABCDEFG-ALL-18269423.TXT
ABCDEFG-ALL-18269521.TXT
QWERTTY-ALL-18269530.TXT
QWERTTY-ALL-18269600.TXT
Result:
ABCDEFGJul01.TXT
QWERTTYJul01.TXT
(Copy and rename only the file with latest sequence no. to another folder)
Is there any basic script that can achieve this?
Question 2
I have a list of files in the same folder which all begins with lines like:
CRM-678A xxxxxxxxxx xxxx
Unit: 1234 xxxxxxxxxxx xxx
I would like to rename each file into (using the above as example):
CRM-678A-1234-01Jun10.txt
Would you please advise a way to make a batch script for the above?
Thanks a lot!
This might get you some of the way
@echo off
for %%a in (*ALL*.txt) do call :EachFile %%a
goto :eof
:EachFile
@echo %1
set FileName=%1
set FileName=%FileName:~0,7%
@echo %Filename%
goto :eof
you can use the %DATE% env variable along with stuff you would find from running "help set" on the command line to do the rest
精彩评论