Batch replace keeping the name

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
steinm07
Junior Member
Junior Member
Posts: 2
Joined: 2017-11-23, 15:52 UTC
Location: /home/steinm07

Batch replace keeping the name

Post by *steinm07 »

I have a folder structure of textures, and there are at least 200 textures.
I want to replace them all with a image of a cat (=ↀωↀ=), but keep the name of the files.
Any easy way?
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Copy one file to many files in sub folder, keep target name!

Post by *Stefan2 »

Hi and welcome!


-open a DOS-Box

-go to main folder of your "folder structure"
(be SURE to be in the right folder!!!)
For example: "D:\rive\MAIN\"



- type
for /F "tokens=*" %A in ('dir /S /B') DO @echo COPY /Y "X:\path\cat.jpg" "%A"

Press the ENTER-key.

Take a look if that copy command looks fine
COPY /Y "X:\path\cat.jpg" "D:\rive\MAIN\path\texture.png"
COPY /Y "X:\path\cat.jpg" "D:\rive\MAIN\path to another\texture.png"
COPY /Y "X:\path\cat.jpg" "D:\rive\MAIN\sub folder\texture.png"
....
.....
.......


To limit to f.ex. *.png files, if necessary, change the DIR command to ('dir /S /B *.png')



If it looks fine, remove the word 'echo ' to make that command really work:
for /F "tokens=*" %A in ('dir /S /B') DO @COPY /Y "X:\path\cat.jpg" "%A"







 
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2steinm07

Based on Stefan2's code you can use this button to do it:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
for /F "tokens=*" %%a in (%L) do copy /Y %P%N "%%a"
wcmicons.dll,62
Copy one file to multiple files (replace their content)


-1
Just copy the green text above - then right click on the button bar and choose "Paste"

Mark all the files you want overwritten and then place the cursor on the file you want to use for the overwriting and click the button.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
steinm07
Junior Member
Junior Member
Posts: 2
Joined: 2017-11-23, 15:52 UTC
Location: /home/steinm07

GREAT!

Post by *steinm07 »

Thank you both, it worked!
Stefan2, it took me a while to figure out what you mean by "DOS-Box", i was thinking "Why the hell this guy whats me to open DOSBox?(A Dos emulator.)"
And the i realised you mean the command prompt/cmd.

KTHXBI
Post Reply