Hey all, it been a while since I've written a script like this. Hopefully you guys can point me in the right direction. What I'm trying to accomplish is moving images, in this case images of CD covers that will be in the parent folder, into the lowest level subdirectory with the same name.
That's where my confusion comes in. I'm not sure how to go about ensuring it's in the lowest level folder. Some folders will have a folder within it of the same name, for example:
Within the parent directory of all my music, there's a band called Periphery, who has a self-titled album called Periphery as well. I would like to have the album art for this album moved into the album folder, and not the band folder.
I think if I can figure this out I will be able to write the rest of the script myself.
Any ideas anyone?
Thanks, Matt.
Can I put a question here?
I'm confused (as usual). Ok, the base folder has: subfolders of groups, AND the cd covers stored under the album's name. But it seems to me, each album must have some association with a group. I don't see where you are getting that association. F/e, you got cd cover called "abbey road", how do you know it's the beatles?
Ah, sorry nbrane! Thank you for taking the time to look at this! I have a folder called "Music". In this folder, I have saved the album art for the majority of the albums I have stored on my computer. Also in this folder I have folders with the artist names, and within those I have folders for each album. The images are saved with the name of the album.
So, I would like to move, for example, "Music\The Here and Now.jpg" to "Music\Architects\The Here and Now\The Here and Now.jpg"
Where Architects is the name of the band, and The Here and Now is the name of the album.
However, there is the case of self-titled albums, where for example "Music\Periphery.jpg" needs to go into the bottom level folder of the same name. In this case "Music\Periphery\Periphery\Periphery.jpg"
Where Periphery is both the name of the band and the name of the album.
Hopefully all of that made sense?
Thank you for your help!
Matt
EDIT: Hmm, I can't say I'm very fond of this new Yahoo! Answers type layout. I can see it being useful for those looking through old posts though.
Can I put a question here?
Oh, ok. (! LIGHTBULB !). I think i see (the light). Maybe this:
::====== begin batch
set xx=
@echo off & setlocal enabledelayedexpansion
set xx=
for %%a in (*.jpg) do (
for /f "tokens=*" %%b in ('dir /b /s /ad "%%~na"') do set xx=%%b
echo copy "%%a" "!xx!"
)
::==== end batch
safety is ON (echo...).
Thank you for your help! What's happening is the images are being copied into the same folder they are currently in, with a filename of '1' and no file type.
I have no clue as to why this is happening though.
Any ideas?
Thank you again!
Matt
Can I put a question here?
maybe a "tokens" issue. No clue where the "1" is coming from unless it's part of the filenames of the .jpgs. Also the f_ing spaces i always forget. Might try this: for /f "tokens=*" %%b in ('dir /b /s /ad "%%~na"') do set xx="%%b"
echo copy "%%a" "!xx!"
)
::==
(see edited post)
don't know if that will help. give it a try and keep'em crossed. If i could read the "1", I could shed more light, but alas...
..
thanks, glad things worked. :-)
Yes! Thank you! Works great. Only issue was that if the file didn't have a matching folder it copied it into the folder from the previous copy. However I think I can fix that myself before I actually run it outside of my test folder.
I believe the '1' contained the image data, similar to if you right clicked an image > open in notepad kind of thing. Not sure where it was getting the name from though.
Thanks for all your help nbrane!
Matt
EDIT: If you still want to see the file, I've uploaded it here. I now realize the reason for the name being 1 is because I had a test folder named "1 2 3", and stemmed from the token issue. ie,
copy file.jpg 1which didn't exist.Thanks again for your help!
Can I put a question here?
