Rename Dos command
#1
Rename Dos command
Can I rename a file in a Batch file to add a unique identifer on it
The orginal file Cricket_1.jpg Add either a % or a _ then a number upto what ever
So the renamed file is Cricket_1&23.jpg
Thanks lads
The orginal file Cricket_1.jpg Add either a % or a _ then a number upto what ever
So the renamed file is Cricket_1&23.jpg
Thanks lads
#3
20K+ Super Poster.
Joined: May 2003
Posts: 20,599
Likes: 0
From: Ramsgate, Kent Drives: E39 530D Touring
you cannot automatically define the identifier (not easily anyway!)
you could use %1 tho
so say batch file is called johnny.bat
you'd say
c:\>johnny.bat 23
and your file would say:
IF %1 = "" ECHO TYPE SOMETHING YOU TWAT
REN CRICKET_1.JPG *%1.*
wich would create CRICKET_123.JPG
you could use %1 tho
so say batch file is called johnny.bat
you'd say
c:\>johnny.bat 23
and your file would say:
IF %1 = "" ECHO TYPE SOMETHING YOU TWAT
REN CRICKET_1.JPG *%1.*
wich would create CRICKET_123.JPG
#4
20K+ Super Poster.
Joined: May 2003
Posts: 20,599
Likes: 0
From: Ramsgate, Kent Drives: E39 530D Touring
to do sequential numbers you'd need NT scripting ideally.
you can do it in batch but you have to set upa control file and have the batch file read+update the control file... its properly complex and a right pain in the arse...
i struggled enough to add dates to filenames, and sequential numbers are even worse!!!!
do a search for batch programming in google, there are some really good websites with examples that helped me a lot... might find an easier method than the one i know of
you can do it in batch but you have to set upa control file and have the batch file read+update the control file... its properly complex and a right pain in the arse...
i struggled enough to add dates to filenames, and sequential numbers are even worse!!!!
do a search for batch programming in google, there are some really good websites with examples that helped me a lot... might find an easier method than the one i know of
#5
20K+ Super Poster.
Joined: May 2003
Posts: 20,599
Likes: 0
From: Ramsgate, Kent Drives: E39 530D Touring
here's a thought... if its a batch file youre only ever gonna run once (ie you dont need it to remember which number it was on then run it again and it remembers) its a peice of piss... you just use the SET command to define a variable, then SET variable = variable +1 and keep using that variable in the file and call it with %variablename
example... type SET at the command prompt and you can see all the pre-defined variables like PATH and stuff...
example... type SET at the command prompt and you can see all the pre-defined variables like PATH and stuff...
#6
cheers Jim bob
If this did the time it would be good.
ren C:\DATA.txt DATA%dd%-%mm%-%yyyy%.txt
We have PA pictures comming comming in Say in the morning called cricket_1.jpg
the next would Cricket_2.jpg
Then in the afternoon different pictures come in with the same name and over right the pictures in the fooking database
say if a put the time in it may help
If this did the time it would be good.
ren C:\DATA.txt DATA%dd%-%mm%-%yyyy%.txt
We have PA pictures comming comming in Say in the morning called cricket_1.jpg
the next would Cricket_2.jpg
Then in the afternoon different pictures come in with the same name and over right the pictures in the fooking database
say if a put the time in it may help
Trending Topics
#8
20K+ Super Poster.
Joined: May 2003
Posts: 20,599
Likes: 0
From: Ramsgate, Kent Drives: E39 530D Touring
johnny, does that %dd% %mm% %yy% thng work in 2k?
if so im gonna feel mighty silly... the program i had to do it was a BIT more complicated than that but it was what i was using on win95
if so im gonna feel mighty silly... the program i had to do it was a BIT more complicated than that but it was what i was using on win95
#9
20K+ Super Poster.
Joined: May 2003
Posts: 20,599
Likes: 0
From: Ramsgate, Kent Drives: E39 530D Touring
Code:
REM @echo off echo.|date|find "Current" >cuXXent.bat echo set date=%%5> current.bat echo e 116 "-" > script echo e 119 "-" >> script echo w >> script echo q >> script type script | debug cu##ent.bat > nul del script > nul call cuXXent.bat rem del cu??ent.bat >nul
#11
20K+ Super Poster.
Joined: May 2003
Posts: 20,599
Likes: 0
From: Ramsgate, Kent Drives: E39 530D Touring
aye that wont work
1st set pa to 1
then set a loop startpoint
then do an if exist to make sure theres a file there to rename (if not exist goto end)
then rename your file
then set pa to pa+1
then loop back to before the if exist
then just bung a :end in there
1st set pa to 1
then set a loop startpoint
then do an if exist to make sure theres a file there to rename (if not exist goto end)
then rename your file
then set pa to pa+1
then loop back to before the if exist
then just bung a :end in there
#12
20K+ Super Poster.
Joined: May 2003
Posts: 20,599
Likes: 0
From: Ramsgate, Kent Drives: E39 530D Touring
you need the loop to run once for each individual file... you cant rename *.jpg to *%pa.jpg as itll try n call em all the same name (what PA is currently set to) and it wont update PA everytime
so command needs to run once, then update pa, then run again etc. etc. etc. untill you if exist command stops finding things existing and stops the batchfile running
so command needs to run once, then update pa, then run again etc. etc. etc. untill you if exist command stops finding things existing and stops the batchfile running
#16
heres an example if u aint already done it?
To change the name of the file SALES.TXT on drive A to NEWSALES.TXT on drive A, enter
ren a:sales.txt newsales.txt
To change the filename extensions to TXT on all files on drive B that have SAL as the first three characters of the main filename, enter
ren b:sal*.* sal*.txt
To change the name of the file SALES.TXT on drive A to NEWSALES.TXT on drive A, enter
ren a:sales.txt newsales.txt
To change the filename extensions to TXT on all files on drive B that have SAL as the first three characters of the main filename, enter
ren b:sal*.* sal*.txt
Thread
Thread Starter
Forum
Replies
Last Post
rsguy
General Car Related Discussion.
44
29-09-2015 04:29 PM