batchscript rename

H

hamlet_X

Hi,

I would like to do a "for in do rename" script with XP. I want to rename
files all with the same name. The digits in the end of the filename depend
on how many files are in the folder like from myfile001.jpg to myfile
218.jpg or somefile01 up to somefile77. I hope I've explained it ok. My
English is not this good.
The other thing is the "devcon remove [ID]". This works fine but when I
remove my Memory Stick device it alway has to be reinstalled afterwards.
When I remove by hand with the mouse not wth a command line it works fine.
There is never a reinstall process when I put in a new MemoryStick.

regards

Herbert
 
P

Phil Robyn

hamlet_X said:
Hi,

I would like to do a "for in do rename" script with XP. I want to rename
files all with the same name. The digits in the end of the filename depend
on how many files are in the folder like from myfile001.jpg to myfile
218.jpg or somefile01 up to somefile77. I hope I've explained it ok. My
English is not this good.
The other thing is the "devcon remove [ID]". This works fine but when I
remove my Memory Stick device it alway has to be reinstalled afterwards.
When I remove by hand with the mouse not wth a command line it works fine.
There is never a reinstall process when I put in a new MemoryStick.

regards

Herbert

- - - - - - - - - - begin screen capture - - - - - - - - - -
<Win2000> C:\CMD>demo\rename87 c:\cmd\txt\*.txt
ren "DUMPVARS.TXT" "DUMPVARS01.TXT"
ren "TIMESRUN.TXT" "TIMESRUN02.TXT"
ren "GETINPUT.TXT" "GETINPUT03.TXT"
ren "MSGBOX1.TXT" "MSGBOX104.TXT"
ren "rename77.txt" "rename7705.txt"
ren "MVSPKG01.TXT" "MVSPKG0106.TXT"
ren "MVSPKG02.TXT" "MVSPKG0207.TXT"
ren "upper.txt" "upper08.txt"
ren "LASTPART.TXT" "LASTPART09.TXT"
ren "getipmsg.txt" "getipmsg10.txt"
ren "DATECALC.TXT" "DATECALC11.TXT"
ren "htmlinpt.txt" "htmlinpt12.txt"
ren "DOHTML.TXT" "DOHTML13.TXT"
ren "CLSPRICE.TXT" "CLSPRICE14.TXT"
ren "SPLITUP.TXT" "SPLITUP15.TXT"
ren "LOKCRACK.TXT" "LOKCRACK16.TXT"
ren "XSUBSTR.TXT" "XSUBSTR17.TXT"
ren "daysago.txt" "daysago18.txt"
ren "ZEROTEST.TXT" "ZEROTEST19.TXT"
ren "SENDCRYP.TXT" "SENDCRYP20.TXT"
ren "this is a longname.txt" "this is a longname21.txt"
ren "calctime.txt" "calctime22.txt"
ren "zfindall.txt" "zfindall23.txt"
ren "~temp.txt" "~temp24.txt"
ren "saveme01.txt" "saveme0125.txt"
ren "~~temp.txt" "~~temp26.txt"
ren "dirsizes.txt" "dirsizes27.txt"
ren "splitfile.txt" "splitfile28.txt"
ren "filemov1.txt" "filemov129.txt"
ren "insertfield.txt" "insertfield30.txt"
ren "rsoon.txt" "rsoon31.txt"
ren "jobschedulers.txt" "jobschedulers32.txt"
ren "dirinfo.txt" "dirinfo33.txt"
ren "Stderr and Stdout to file.txt" "Stderr and Stdout to file34.txt"
ren "deloldsubs.txt" "deloldsubs35.txt"
ren "tail.txt" "tail36.txt"
ren "NTUrls.txt" "NTUrls37.txt"
ren "Clay Calvert Set.txt" "Clay Calvert Set38.txt"
ren "dosurls.txt" "dosurls39.txt"
ren "cmdlinetricks.txt" "cmdlinetricks40.txt"
ren "NTFS vs FAT File Systems.txt" "NTFS vs FAT File Systems41.txt"

<Win2000> C:\CMD>rlist c:\cmd\demo\rename87.cmd
=====begin c:\cmd\demo\rename87.cmd ====================
01. @echo off
02. setlocal
03. set filespec=%1
04. pushd %~dp1
05. set ctr=100
06. for /f "tokens=*" %%a in (
07. 'dir /b %filespec%'
08. ) do call :rename "%%a"
09. popd
10. goto :EOF
11. :rename
12. set /a ctr+=1
13. echo ren %* "%~n1%ctr:~1%%~x1"
14. goto :EOF
=====end c:\cmd\demo\rename87.cmd ====================
- - - - - - - - - - end screen capture - - - - - - - - - -

If the preceding does what you intend, than delete the word
'echo' from line 13 to actually rename the files.

Sorry, can't help with the Memory Stick question.
 
H

hamlet_X

Sorry Phil, I didn't explain myself very good. So I try again
and tell the whole story. The following script is the beginning.
I take all the files from the memory stick and tell with %1 what the
folders name should be. And then I want all the files in there folders
get the name of %1 the name of there folder. You know I'm an absoloutly
beginner but this script would help my work a lot.
herbert

@echo off
set A="E:\Sony\Fotos"
set B="E:\Sony\Filme"
set C="E:\Sony\WortBilder"
set H="E:\Sony\HiRes"
set D="I:\DCIM\100MSDCF"
set E="I:\MSSONY\MOML0001"
set F="I:\MSSONY\MOMLV100"
set G="I:\MSSONY\IMCIF100"


if exist %D%\*.JPG md %A%\%1
if exist %D%\*.JPG xcopy %D%\*.JPG %A%\%1
if exist %D%\*.JPG del %D%\*.JPG/q

if exist %E%\*.MPG md %B%\%1
if exist %E%\*.MPG xcopy %E%\*.MPG %B%\%1
if exist %E%\*.MPG del %E%\*.MPG/q

if exist %F%\*.MPG md %C%\%1
if exist %F%\*.MPG xcopy %F%\*.MPG %C%\%1
if exist %F%\*.MPG del %F%\*.MPG/q

if exist %G%\*.TIF md %H%\%1
if exist %G%\*.TIF xcopy %G%\*.TIF %H%\%1
if exist %G%\*.TIF del %G%\*.TIF/q

devcon remove USBSTOR\DiskSony____MSAC-US1________1.00
 
H

hamlet_X

Thank you Phil for your advice. I'm sorry because of my first long answer
and I didn't mention your nice way to answer so immediatly with this
complicated script. Now I try to figure it out by my own with it and I've
already learned a lot. Thanks and don't be angry with me.
regards
Herbert
 
P

Phil Robyn

hamlet_X said:
Thank you Phil for your advice. I'm sorry because of my first long answer
and I didn't mention your nice way to answer so immediatly with this
complicated script. Now I try to figure it out by my own with it and I've
already learned a lot. Thanks and don't be angry with me.
regards
Herbert

Hi, Herbert:

I'm not 'angry' with you; I just don't have a very clear idea of what it is
that you want to do, or how the renaming of files using some sort of sequential
numbering scheme is supposed to be related to the batch file that does all the
XCOPYing of files and deleting of directories.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Auto Rename Files 2
Rename jpg file using vba 2
Gif access is denied? 9
Renaming Groups of Files 3
Rename files 3
Renaming multiple files 1
Can't save renamed DataColumn 1
Outlook 2007 renames attachments 4

Top