flatuswalrus Posted January 13, 2019 Share Posted January 13, 2019 Hi all, just wondering if there was any individuals who may be able to help me. I wish to copy the image titled 1.jpg in the folder shown below and name it to match all of the folders: I had a batch file I used previously to copy an image and name it the same as a bunch of .wad files I had: for %%a in ("G:\Doom\*") do (copy "C:\Users\Dane\Pictures\Doom.jpg" "G:\Doom\%%~na.png") I have tried to bastardize it but without success. Does anyone know how to change it to suit what I wish to do with it now? Thank you. Quote Link to comment Share on other sites More sharing options...
dragon57 Posted January 13, 2019 Share Posted January 13, 2019 Try this: for /d %%a in (".\*") do (copy 1.jpg "%%a\%%a.jpg") Run the command from the Images directory. 1 Quote Link to comment Share on other sites More sharing options...
proghodet Posted January 13, 2019 Share Posted January 13, 2019 (edited) @dragon57 posted an elegant answer in batch while I was in the process of writing a python script for the same purpose. I figured I might just post it anyway from os import listdir from os import rename from shutil import copy path = 'C:\\Users\\Dane\\LaunchBox\\Images' imagefile = path + '\\1.jpg' folders = [f for f in listdir(path)] for folder in folders: try: copy(imagefile, path + "\\" + folder + ".jpg") except FileNotFoundError: print(folder + " was not found") continue Edited January 13, 2019 by proghodet 1 Quote Link to comment Share on other sites More sharing options...
dragon57 Posted January 13, 2019 Share Posted January 13, 2019 Variety is the spice of retro life! Good job, @proghodet. 1 Quote Link to comment Share on other sites More sharing options...
flatuswalrus Posted January 13, 2019 Author Share Posted January 13, 2019 Thank you very much both for your reply. @dragon57 I tried it, but it did not work. Do you notice anything obviously incorrect in what I have done?: for /d %%a in ("C:\Users\Dane\LaunchBox\Images*") do (copy "C:\Users\Dane\LaunchBox\Images\1.jpg" "%%a\%%a.jpg") @proghodet I will have to look up what a python on script is as I have never heard of it before. Quote Link to comment Share on other sites More sharing options...
dragon57 Posted January 13, 2019 Share Posted January 13, 2019 If you run my command without any edits from the Images directory, it should work fine. I have tested it here repeatedly. 1 Quote Link to comment Share on other sites More sharing options...
flatuswalrus Posted January 13, 2019 Author Share Posted January 13, 2019 (edited) 1 hour ago, dragon57 said: If you run my command without any edits from the Images directory, it should work fine. I have tested it here repeatedly. How bloody silly of me, thank you so much. It sure did work. Thank you very much for your help, it is much appreciated. I tried to get my head around learning how to do it before asking but my aptitude/understanding for this kind of stuff has not quite clicked yet. EDIT: I should have stipulated so my bad but I wanted the images to appear in the folder that 1.jpg is so I can easily cut them to paste somewhere else. I tried searching for ".jpg" in the images folder but about 27k images show up, I tried sorting by date but unfortunately I will have to pull them out of each folder manually. Silly me for not saying that. EDIT 2: I just manually grabbed them from each folder which only took about 5 minutes. Thanks again. Edited January 13, 2019 by Dane Quote Link to comment Share on other sites More sharing options...
proghodet Posted January 13, 2019 Share Posted January 13, 2019 Ah, my bad, I should have explained better. Even though you got it fixed now, I'll post the instructions on how you would use it: You would need python installed on your system. You can check if you already have it installed by opening the command prompt, and typing python --version, and pressing enter. If not, you can download it from python.org. With python installed, you can copy the code i pasted above into a text-file (using notepad or similar), save the file as copyimages.py, and then just double click the file 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.