bat file pictures rename

March 16, 2011 at 09:42:51
Specs: Windows XP
Hello,
I am looking for bat file which renames the files (one or several) in many subfolders with the name of the corresponding subfolder and a counter (preserving the extensions)
For example I have a folder "photos" with lot of subfolders like "my vacation", "going-crazy", "the stupid cat of my wife" etc. Every subfolder contains some picture files - one or several. What I need is (if possible of course) with a single click to rename all the files in the subfodlers with the name of the subfolder - so in "my vacation" to appear the files my vacation-01.jpg, my vacation-02 jpg etc; in "going-crazy" - going-crazy-01, going crazy-02 etc. I prefer "-" in the names instead of "space" because I am not sure what exactly may happen when I insert the images in HTML pages and they are with spaces instead of "-".

Thanks in advance
Handel


See More: bat file pictures rename

Report •


#1
March 16, 2011 at 14:52:37
what will be the directory depth ? I mean will there be another subfolder inside "going crazy" ?

Subhash Chandra.


Report •

#2
March 16, 2011 at 16:34:31
No, no - just a lot of single level subfolders.

Report •

#3
March 16, 2011 at 16:53:32
Thats good..one more questions. What is directory path where the main folder is .

Like the sunfolder start from "C:\somewhere\somewhere\" ?

Sorry for this question but its imp for me to know so i can implement in the script

Subhash Chandra.


Report •

Related Solutions

#4
March 16, 2011 at 17:12:29
I usually call the main directory "images1" etc; I am not sure I understand the question - I presumed I will put the bat file in the parent directory ie "images1" but it may be any name; as for the path to there it is different and rather random; so the directory tree is something like this:
---parent directory where I suppose I will put the bat file---
sub-folder 1 | sub-folder 2 | ... ... |sub-folder N|
photo photo photo
photo photo photo
photo photo photo


Report •

#5
March 16, 2011 at 17:44:07
Anyway, Try this from a batch file, Put this in parent directory.

========================================
@echo off & setlocal enabledelayedexpansion
for /d %%a in (*.*) do (
echo current directory = %%a
pushd %%a
set /a count=1
for /f "tokens=*" %%b in ('dir /b *.*') do (
ren %%b %%a-!count!%%~xb
set /a count=count+1
)
popd
)

=======================================

create a temp folder on your system and some sample folder to simulate the same scnario, run the batch there, if it does as expected then run on real folder

Subhash Chandra.


Report •

#6
March 16, 2011 at 18:04:07
Thank you, it works like a charm!
Can you adjust one small thing please - can you make the numbering to be 01, 02...10,11 etc - not 1,2... 10,11 etc? I have already renamed disks and would prefer the names to follow the same convention?

Report •

#7
March 16, 2011 at 19:11:59
========================================
@echo off & setlocal enabledelayedexpansion
for /d %%a in (*.*) do (
echo current directory = %%a
pushd %%a
set /a count=01
for /f "tokens=*" %%b in ('dir /b *.*') do (
ren %%b %%a-!count!%%~xb
set /a count=count+1
)
popd
)

try this
=======================================

Subhash Chandra.


Report •

#8
March 17, 2011 at 06:38:58
I already tried it; it does the same:-(
Anyway - I can use this, thank you very much!

Report •

#9
April 5, 2011 at 00:35:39
Hello...
I'm a total newby to all this & I would really appreciate some help with batch files written is notepad and executed in windows XP.

I would like to write a .bat file that will move files (all picture formats- .jpeg .bmp AND all video formats- .mpeg .mp4 .avi .flv and any other format there is) from my F: to F:PERSONAL\D folder.

The F:PERSONAL\D folder already exists.... IF the filename which i am moving already exists in F:PERSONAL\D folder, then rename, NOT overwrite.

Thank you very much in advance.
-Adam


Report •

#10
April 5, 2011 at 12:13:33
@adamrashid .. please post your question in a new thread.So experts can get notified.

I believe what you asked can be done easily and someone will come up with a solution soon.

Subhash Chandra.


Report •


Ask Question