मैं हाल ही में इस समस्या से निपटने के लिए किया था, और कई फाइलों कि मैं पदानुक्रम से एक ही फ़ोल्डर के लिए करने के लिए जाना चाहते थे एक दूसरे के रूप में एक ही नाम था, और मैं करने के लिए उन्हें बिना अभी भी पदानुक्रम समतल करना चाहता था अधिक लिखा जा रहा है। मैं क्या किया था एक स्क्रिप्ट है कि फाइल ले जाता है लिखते हैं, लेकिन नाम पर वर्ष पदानुक्रम पथ साथ यह नाम बदलता उदाहरण के लिए: स्रोत फ़ाइलें:
C: \ फ़ाइलें \ somefiles \ file.txt
C: \ फ़ाइलें \ otherfiles \ file.txt
गंतव्य C: \ newdir \ फ़ाइलों
रूप में बनाया जाता 210
C: \ newdir \ somefiles-file.txt
C: \ newdir \ otherfiles-file.txt
यहाँ
कोड, बैच फ़ाइल 1 फ़ाइलों के माध्यम से चला जाता है है, बैच फ़ाइल 2 नाम बदलता है और उन्हें (चाल भी बजाय नकल कर सकता है, यदि आप स्रोत सुरक्षित रखना चाहते हैं:
@echo off
for /r %%f in (*.*pr) do @renameandmovefilespart2.bat "%%f" "%%~ff" "%%~xf"
renameandmovefilespart2.bat
@echo off
Setlocal EnableDelayedExpansion
rem set the whole file path
set origWhole=%1
set origPathOnly=%2
set extension=%3
rem here you can set where the directory to hold the flattened hierarchy is
set destDir=c:\destinationDir\
rem set the directory to do a string replace
rem make this the starting directory, that you dont want in the newly renamed files
set startingDir=C:\starting\directory\
set nothing=
set slash=\
rem here you can set what the character to represent the directory indicator \ in the new files
set reaplcementDirectoryCharacter=--
set quote="
rem cut out the starting part of the directory
call set newname=%%origWhole:!startingDir!=!nothing!%%
rem replace slashes with new character
call set newname=%%newname:!slash!=!reaplcementDirectoryCharacter!%%
rem remove quotes
call set newname=%%newname:!quote!=!nothing!%%
rem @echo shortened: %newname%
rem @echo source path: %origPathOnly% newPath: %startingDir%
rem @echo extension: %extension%
rem rename the files
ren %origWhole% %newname%
rem prepare to move the file, clean up the source path
call set origPathOnly=%%origPathOnly:!quote!=!nothing!%%
move "%origPathOnly%%newname%" "%destDir%"
संभावित डुप्लिकेट [रोबोकॉपी के साथ सभी फ़ोल्डरों को छोड़ने वाले फ़ोल्डर पेड़ से फ़ाइलों की प्रतिलिपि कैसे करें?] (Http://stackoverflow.com/questions/1502170/how-to-copy-files-from-folder-tree-dropping -ल-फ़ोल्डर्स-साथ-रोबोकॉपी) –