There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Windows XP
Tag Cloud
adware audio bios blue screen boot bsod computer connection crash dell drivers error excel firefox freeze google hard drive hardware hijackthis install internet laptop linux malware network no sound outlook problem reboot recovery redirect router screen server slow sound speakers spyware startup trojan usb video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Windows XP >
Recursive bash script or cmd to copy folder.jpg

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
sorrow's Avatar
Computer Specs
Member with 79 posts.
 
Join Date: Nov 2006
Experience: Intermediate
14-Mar-2008, 03:07 AM #1
Question Recursive bash script or cmd to copy folder.jpg
Hi, I'm running WinXP Pro SP2 (fully updated) and trying to create either a manually run command line tool, or a bash script for later use. The objective is to go through my root music folder and copy all of the zunealbumart.jpg and / or zunecustomalbumart.jpg files and paste them into the same directory now named folder.jpg

So far I have gotten this command to get close, but it comes back telling me that "The system cannot find the file specified." Any ideas?

Code:
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music>for /R %d in ("c:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\") do copy %dz*.jpg %d\folder.jpg
This is in a test directory, but I'll eventually be running it on an external hard drive in a similar directory tree.

Cheers!
Edit - oh, and I got that idea mostly from here: http://forums.xkcd.com/viewtopic.php?f=11&t=14965

Last edited by sorrow : 14-Mar-2008 03:21 AM.
devil_himself's Avatar
Distinguished Member with 4,921 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
14-Mar-2008, 03:43 AM #2
Is This What You Want ?

Code:
@echo off
setlocal
pushd "c:\pictures"
for /f "tokens=*" %%a in ('dir /b /a-d /s zune*.jpg') do copy "%%a" "c:\new pictures"
popd
endlocal
sorrow's Avatar
Computer Specs
Member with 79 posts.
 
Join Date: Nov 2006
Experience: Intermediate
14-Mar-2008, 03:56 AM #3
I think its very similar to what I'm looking for, but I'm hoping to put the new folder.jpg files into the same folder as the original .jpg
devil_himself's Avatar
Distinguished Member with 4,921 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
14-Mar-2008, 05:06 AM #4
Yes .. Why Not

Code:
@echo off
setlocal
set /a cnt=1
pushd "c:\pictures"
for /f "tokens=*" %%a in ('dir /b /a-d /s *.jpg') do call :PROCESS "%%a"
popd
endlocal
goto :EOF
:PROCESS
copy %1 folder%cnt%.jpg
set /a cnt+=1
devil_himself's Avatar
Distinguished Member with 4,921 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
14-Mar-2008, 05:27 AM #5
Lol ..i'm Confused ...

Lets say their is a folder in C:\pictures .... inside C:\pictures their are Multiple folders ... all folders have only 1 picture inside it .. you need to copy and rename it to the same folder ...

Code:
@echo off
setlocal
pushd "c:\pictures"
for /r %%a in (.) do copy %%a\*.jpg %%a\folder.jpg
popd
endlocal

FOR /R - http://www.ss64.com/nt/for_r.html
sorrow's Avatar
Computer Specs
Member with 79 posts.
 
Join Date: Nov 2006
Experience: Intermediate
14-Mar-2008, 05:32 AM #6
Still nothing -- I wish that I knew more about bash scripts so I could be at least somewhat helpful on this!

Here is the sample directory that I'm running it on so you can get a better idea. I'm trying to have the folder.jpg in the same folder as the original zunealbumart.jpg
Code:
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\dir.txt
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Live @ Coachella 2007
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 01 - People Of The Sun.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 02 - Bulls On Parade.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 03 - Vietnow.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 04 - Revolver.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 05 - Snakecharmer.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 06 - Tire Me.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 07 - Down Rodeo.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 08 - Without A Face.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 09 - Wind Below.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 10 - Roll Right.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\Rage Against The Machine - Evil Empire - 11 - Year Of Tha Boomerang.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\ZuneAlbumArt.jpg
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Evil Empire\ZuneCustomAlbumArt.jpg
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Live @ Coachella 2007\Rage Against The Machine - Live @ Coachella 2007 - 01 - People Of The Sun.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Live @ Coachella 2007\Rage Against The Machine - Live @ Coachella 2007 - 05 - Bullet In The Head.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Live @ Coachella 2007\Rage Against The Machine - Live @ Coachella 2007 - 05 - Bulls On Parade.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Live @ Coachella 2007\Rage Against The Machine - Live @ Coachella 2007 - 06 - Know Your Enemy.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Live @ Coachella 2007\Rage Against The Machine - Live @ Coachella 2007 - 09 - Down Rodeo.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Live @ Coachella 2007\Rage Against The Machine - Live @ Coachella 2007 - 10 - Bombtrack.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Live @ Coachella 2007\Rage Against The Machine - Live @ Coachella 2007 - 11 - Testify.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Live @ Coachella 2007\ZuneCustomAlbumArt.jpg
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\Rage Against The Machine - Rage Against The Machine - 01 - Bombtrack.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\Rage Against The Machine - Rage Against The Machine - 02 - Killing In The Name.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\Rage Against The Machine - Rage Against The Machine - 03 - Take The Power Back.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\Rage Against The Machine - Rage Against The Machine - 04 - Settle For Nothing.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\Rage Against The Machine - Rage Against The Machine - 05 - Bullet In The Head.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\Rage Against The Machine - Rage Against The Machine - 06 - Know Your Enemy.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\Rage Against The Machine - Rage Against The Machine - 07 - Wake Up.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\Rage Against The Machine - Rage Against The Machine - 08 - Fistful Of Steel.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\Rage Against The Machine - Rage Against The Machine - 09 - Township Rebellion.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\Rage Against The Machine - Rage Against The Machine - 10 - Freedom.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Rage Against The Machine\ZuneAlbumArt.jpg
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 01 - Microphone Fiend.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 02 - Pistol Grip Pump.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 03 - Kick Out The Jams.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 04 - Renegades Of Funk.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 05 - Beautiful World.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 06 - I'm Housin'.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 07 - In My Eyes.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 08 - How I Could Just Kill A Man.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 09 - The Ghost Of Tom Joad.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 10 - Down On The Street.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 11 - Street Fighting Man.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\Rage Against The Machine - Renegades - 12 - Maggie's Farm.mp3
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Machine\Renegades\ZuneCustomAlbumArt.jpg
devil_himself's Avatar
Distinguished Member with 4,921 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
14-Mar-2008, 05:42 AM #7
The Script I Posted In Post #5 Should Do It
sorrow's Avatar
Computer Specs
Member with 79 posts.
 
Join Date: Nov 2006
Experience: Intermediate
14-Mar-2008, 05:48 AM #8
I've tried it in a couple of different ways without luck.. I've put it one of the subdirectories, tried changing the "c:\pictures" to both the directory & the subdirectory, but so far haven't had any luck Oh, and I also tried it copying it directly into the bash file as it was.
devil_himself's Avatar
Distinguished Member with 4,921 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
14-Mar-2008, 05:56 AM #9
Give This a Shot ... This is a Batch[cmd] Script Not Bash .

Batch file - http://en.wikipedia.org/wiki/Batch_file
Bash - http://en.wikipedia.org/wiki/Bash

Code:
@echo off
setlocal
set root=C:\pictures
 
for /f "tokens=*" %%g in ('dir "%root%" /A:D /B') do (
 for /f "tokens=*" %%h in ('dir "%root%\%%g" /A:D /B') do (
  for %%i in ("%root%\%%g\%%h\*.jpg") do copy "%%i" "%root%\%%g\%%h\folder.jpg"
  
 )
)
Assumes Their Are only Two Higher Directories After The Root Folder

Like -- C:\Pictures\Folder1\Folder1

Not Like - C:\Pictures\Folder1\Folder1\another fodler
sorrow's Avatar
Computer Specs
Member with 79 posts.
 
Join Date: Nov 2006
Experience: Intermediate
14-Mar-2008, 06:14 AM #10
Ok, now I'm just at a loss - in my limited knowledge of these things it seems like that must work, but still no luck! Is there a way to prevent the batch (and thank you for clarifying that) from closing so I can see what kind of output the terminal is giving - and show it to you?
devil_himself's Avatar
Distinguished Member with 4,921 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
14-Mar-2008, 06:18 AM #11
Open Command Prompt ... Start > Run > cmd

navigate To The Path Where The Script Is Placed

If It Is Placed At Desktop

Then

Cd Desktop

If The Name Of The Script Is recurse.bat

Then

Recurse.bat
sorrow's Avatar
Computer Specs
Member with 79 posts.
 
Join Date: Nov 2006
Experience: Intermediate
14-Mar-2008, 06:22 AM #12
Odd- shouldn't there be some output when I run the bat? I've navigated to the folder in question & run the script, but nothing happens.
devil_himself's Avatar
Distinguished Member with 4,921 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
14-Mar-2008, 07:07 AM #13
Here Ya Go Again .. lol Kill Me If This Didn't Worked

save as "Recurse.bat" With Quotes

Code:
@echo off
pushd "c:\pictures"
setlocal
for /f "tokens=*" %%a in ('dir /a /b /s *.jpg 2^>NUL') do call :PROCESS "%%a" "%%~da%%~pa"
goto :EOF
:PROCESS
copy %1 "%~2folder.jpg"
sorrow's Avatar
Computer Specs
Member with 79 posts.
 
Join Date: Nov 2006
Experience: Intermediate
14-Mar-2008, 07:40 AM #14
Ahhh, now its definitely close! I ran it via double clicking the file and nothing happened, but when I accessed it via the command line - well here is a snip of the output:
Code:
C:\Documents and Settings\insanity.FIDO\Desktop\Temp Music\Rage Against The Mach
ine\Renegades\ZuneCustomAlbumArt.jpg
The system cannot find the file specified.
        0 file(s) copied.
devil_himself's Avatar
Distinguished Member with 4,921 posts.
 
Join Date: Apr 2007
Location: India
Experience: Advanced
14-Mar-2008, 07:47 AM #15
Tell Me The Output

Code:
@echo off
pushd "c:\pictures"
setlocal
for /f "tokens=*" %%a in ('dir /a /b /s *.jpg 2^>NUL') do echo %%a & call :PROCESS "%%a" "%%~da%%~pa"
goto :EOF
:PROCESS
Echo copy %1 "%~2folder.jpg"
pause
To Copy Everything From The Command Box .. Right Click .. Select All ... Hit Enter To copy
Closed Thread Bookmark and Share

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 07:51 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.