Hello,
I would like to know what batch commands I can to to rename files in directory called \\gbr1w001\data_transfer_gb77$
INVPRT_5023949000004_20080818061329_0000979.GB ---> 5023949000004_MSG_IN_20080818061329_0000979.GB
PPRHDR_5000119000006_20080721061424_00000981.GB_m ---> 5000119000006_MSG_IN_20080721061424_00000981.GB_m
SLSRPT_5023949000004_20080721061317_00000978.GB ---> 5023949000004_MSG_IN_20080721061317_00000978.GB
Basically I would like to drop 7 characters at the begining of the file and insert MSG_IN_ after next 14 characters.
Any help on this will be most appreciated.
Thank you
Configuration: Windows XP Internet Explorer 7.0
Heres my example of renameing a folder in a directory supplied by the user in a batch file:
|
Reply to satya
|
The following biterscripting script will do just that. To download biterscripting free, go to their website at biterscripting.com .
|
Reply to erasmus
|
Reworded quote i want to rename files a1.txt, a2.txt ...aN.txt files to a1-v1.xt ...aN-vN.txt . This bitescript will do it. I will assume your files are in folder C:\folder.
# Change dir to C:\folder.
cd "C:\folder"
# Get a list of files a*.txt.
var str list ; lf -n "a*.txt" > $list
# Process files one by one.
while ($list <> "")
do
# Get the next file in the list.
var str file ; lex "1" $list > $file
# Get the sequence number. It is between a and .txt
var str seq ; stex -p -r -c "^a&\.txt^" $file > $seq ; stex -c "^a^]" $seq > null ; stex -c "[^.txt^" $seq > null
# New file name is a$seq-v$seq.txt
var str newname ; set $newname = "a"+$seq+"-v"+$seq+".txt"
# Rename file
echo -e "Renaming file " $file " to " $newname
system rename ("\""+$file+"\"") ("\""+$newname+"\"")
done
Save the script as C:\Scripts\rename.txt. Start biterscripting. Enter the following command. script rename.txt That's it. Donwload biterscripting if necessary from http://www.biterscripting.com . It is free. Don't forget to change C:\folder in the script to the correct folder path. Good luck. Sen |
Hi,
|