简体   繁体   中英

script to move all files into one folder

I would like to move all folders under %USERPROFILE%\\Documents into one folder
1- I created the folder

@echo off   
md Personal
pause

2- I am trying to move all the files in Documents to one folder --> personal

@echo off
Move "%USERPROFILE%\Documents" *.* "%USERPROFILE%\Documents\Personal"
pause

but it's not working?
%USERPROFILE%\\Documents I need to send it to 10 users to run the batch file-

your help would be appreciated thank you

Tameem

As you have this tagged as PowerShell, here is the PowerShell solution.

# Create folder
New-Item -Path "$env:USERPROFILE\Documents\Personal" -ItemType Directory
# Move all files from Documents to Personal
Get-ChildItem -File "$env:USERPROFILE\Documents\" | Move-Item -Destination "$env:USERPROFILE\Documents\Personal"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM