How to move all filetypes in subfolders with CMD

preview_player
Показать описание
EXPLANATION AND CODE BELOW:

code:
for /r %%a IN (*.*) do (
move /y "%%a" "%cd%"
)

explanation:
for = command

/r = affects all subfolders and not just current folder

%%a = variable used to move files

IN = command

(*.*) = decides what file names/types will be affected, star (*) means everything

do = command

move = command

/y = prompts for confirmation if you want to overwrite (not needed)

"%%a"= uses the a variable to move one file at the time, i use quotation marks because if you have a file with a empty space inside it will not work

"%cd%"= cd stands for CURRENT DIRECTORY, which means the folder the .bat file is opened in. You can replace "%cd%" with a PATH of your choice. For example move /y "%%a" "C:\Users\huehue\Desktop\pussyslayer69"
Рекомендации по теме
Комментарии
Автор

this is so helpful. i don't know why no one else on the internet (that i've found) could explain this so clearly.

Aarozinho
Автор

Deserves 50, 000, 000, 000 likes, one for each second of time you have saved the world!

sammikelic
Автор

I had gone around the internet to find a script and I found it in your video. It was exactly what i wanted. Very short and nice script. Thank you very much.

chakrang
Автор

This saved me a lot of time, thanks for sharing!

admjski
Автор

Beautifully simple and exactly what I needed. You, sir, are a legend :)

TheGamingClassic
Автор

Thanks man! You saved my afternoon and maybe tomorrow's too!

shayboucher
Автор

thank you, this is what I am looking for ❤

eric
Автор

while moving same name files what will happen, it will overwrite or keep both files with different names

prabuubarp
Автор

greats, thank a lot for your help, its saved my day

adminsurvey
Автор

I used your program to flatten some folders with pictures in it. But then I noticed that the folders weren't empty because the Thumbs.db files were still there.
How do I need to change the code so that all hidden files and system files are affected, as well?

WadelDee
Автор

It worked for me.
But it would be nice if the program also deletes all empty folders afterwards.
What do I have to write after the code if I also want all empty folders to be deleted afterwards?
(I say all empty folders in case the moving didn't work for whatever reason.)

WadelDee
Автор

Great tutorial! Is there a way to move files from subfolders to parent folder (not root folder where .bat is locate)? I have a ton of folders (more than 10, 000) with subfolders and I need to move every subfolders files to parent directory. I’ve look everywhere, but not found easy way to that. Thanks again!

Marboes
Автор

GREATEST. VIDEO. EVER. Liked AND sub EARNED.

Q: Is there a switch I can use to ignore a specific folder? For example, using your above, how can I go through all directories EXCEPT "c:\documents" ?

StreamLauncher
Автор

Great tutorial! How do I do this for multiple files at once? Thank you.

tayoajegbile
Автор

I've done Crap... should have read the description first... /y screw Tons of fotos... but good code anyway, my bad i didnt read it... Anyway to reverse it?

enky
Автор

There is a reverse command to main folder ti subfolders?

leonardogambini
Автор

but all the files in main folders were moved completely not copied so if we want to see the files in subfolders with specific folder we cant see them again in same way, so solution to this is.-- given below

instead of move we can use COPY so that we can retain the files in main folders as well and copy to new folder as well. i tried and it worked 😀

itstime
Автор

worked pefectly...teach me how to become a pro in cmd

Blacksugar
Автор

"\pussyslayer69" tho LOL
thx for the video and the laugh!

bluskyline
Автор

fuck ihad 8000 files now it's replaced become 2000, can't be undone

FarisThe
welcome to shbcf.ru