a fast way to replace 1000+ files?
Does anyone know of a command or software that can copy and replace multiple files? I have about 1600 different bitmap files in a folder that needs to be replaced by copies of a single white bitmap, and it will take some major effort to copy and rename every single file manually.
|
Not sure about the utility of
...replaced by copies of a single white bitmap... Pretty sure that it'll do what you want. But there's probably a cheaper way to do it in MS-DOS...?! ;) |
2nd attempt, 1st one crashed the thread and got deleted.
Assuming you are using Windows and have Excel or the OO counterpart, there is a away using DOS commands. It's a bit annoying but there's nothing else I could think of except googling for a tool that does the same with less legwork. 1) Create a .txt file in your target folder (the one with the 1000+ files) and rename it to something like step1.bat. Windows will warn you about the extension, but it's okay. 2) Right-click on the text file and edit it to contain this command: dir /B >filelist.txt 3) Save the file and close it. 4) Double-click step1.bat to run it. You'll have a file list called filelist.txt in no time. 5) Open filelist.txt in Excel. Excel will ask a couple of questions but the answers should be obvious. You now have the list of target names on column A 6) Move the target names to column C, fill column A with xcopy and column B with the name of your source file, including extension. Fill column D with /Y unless you want to confirm each overwrite. Each line in your Excel file should look something like this: Xcopy sourcename.bmp targetname.bmp /Y 7) Save this as step2.txt in your target folder (make sure file format is still .txt and not XLS) and then rename to step2.bat using the Explorer or something like that 8) Copy the source file to the target folder 9) Read this warning: if all was done right and all goes according to plan running step2.bat will overwrite your original bmps. There is no way to recover them once the batch file was run. Better create a backup first. 10) Run step2.bat, check all was copied ok and clean away the temporary files That's it, sounds more complicated than it is, really. Feel free to PM me for clarification. However, if someone knows a better way, I am eager to hear it as I use the above process a lot. |
It worked! Many thanks DUS SLF! :ok:
I thought about the Xcopy command but I didn't know about the Excel trick. |
Late as ever.
For those without Excel (a brilliant piece of lateral thinking BTW). First ensure that the new file blank.bmp has been copied to the existing oldpix data folder & then create the following batch file (my_name.bat) in a convenient location (e.g. root), modifying folder/file names and paths as necessary. MD c:\newpix CD c:\oldpix MOVE blank.bmp c:\newpix DIR /B > c:\newpix\filelist.txt CD c:\newpix FOR /f %%n IN (filelist.txt) DO COPY c:\newpix\blank.bmp c:\newpix\%%n |
A small addendum to the pipe command:
If you wish to pipe (>) the output of a command to an existing file just use >> to the filename. SD |
|
This is a prime example of why downloading bash for Windows and the Unix Utils (all free) is very useful. 1 line, no hassle.
for i in `ls c:\oldpix` ; do cp c:\newpic.bmp c:\oldpix\$i ; done :ok: |
This is a prime example of why downloading bash for Windows and the Unix Utils (all free) is very useful. 1 line, no hassle.
Unfortunately I can't paste it, due to the idiotic smiley crap which messes with everything in sight. |
Originally Posted by Shunter
(Post 4708387)
This is a prime example of why downloading bash for Windows and the Unix Utils (all free) is very useful. 1 line, no hassle.
for i in `ls c:\oldpix` ; do cp c:\newpic.bmp c:\oldpix\$i ; done :ok: |
Mac
The last time I wrote batch files in anger I had to type copy con: my_file.ext at the DOS prompt and terminate the text with ^Z and a quaint thing called a carriage return (anything was better than edlin). But my %%n is a variable and not a parameter so I don't think the shift command is syntactically relevant (chemo brain...I even lost my specs in the snow...so I am happy to stand corrected). SD? As I said, I did test the 'program' after I scribbled it down and before posting. Very quick and dirty, no errorlevel, if exist, if not exist checks and no clean up afterwards. But non-destructive, at least.
Of course, the source and destination paths and file names could be passed as parameters (%1..%9) from the command line in which case the shift command might become pertinent (that's something for you to do, Homer, find that out). But all the meat is in the last line (which is essentially the Bash command suggested by Shunter), which was sufficient to answer the OP's question. Thanks for the page linked to, though, which I have saved to disk and will study later; Microsoft's help page for XP batch file commands is very limited in its scope. Looks like you're expected to part with even more money for books which used to be supplied with the OS (GW Basic reference, command line reference, batch file reference). For a really hard core batch file (whose workings I don't for a moment pretend to understand) have a look at this: Stupid Coding Tricks: A Batch of Pi - The Daily WTF FOR /f %n IN (filelist.txt) DO COPY /Y blank.bmp %n can be entered at the command prompt in source=target directory but is destructive. IRN |
Script to copy over 1600 bitmap files
Massey1Bravo has the following requirement:
Does anyone know of a command or software that can copy and replace multiple files? I have about 1600 different bitmap files in a folder that needs to be replaced by copies of a single white bitmap, and it will take some major effort to copy and rename every single file manually. I will write a script for you. I will assume the following. 1. You have over 1600 bitmap files in the folder "C:/Bitmaps" and, possibly, its subfolders. Their file extension is .bmp. 2. You want to copy over each of these files a single white bitmap stored at "C:/MasterBitmap.bmp". (I will admit that I am following one of the sample scripts that came with biterscripting - so this is not all my original work.) Code:
Save the script in some file (say, C:/X.txt), start biterscripting and run the command Code:
script "C:/X.txt" Let me know if this works for you. Randi |
I have about 1600 different bitmap files in a folder that needs to be replaced by copies of a single white bitmap := |
All times are GMT. The time now is 23:06. |
Copyright © 2024 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.