[batch] move folders and files
nono313
Posted messages
196
Status
Membre
-
nono313 Posted messages 196 Status Membre -
nono313 Posted messages 196 Status Membre -
Hello,
I am a beginner in batch
I wrote a script that allows me to move everything in one folder to another folder.
The problem is that it only moves files and not the folders that are in /subfolder/
I am a beginner in batch
I wrote a script that allows me to move everything in one folder to another folder.
move ".\subfolder\"* .\
The problem is that it only moves files and not the folders that are in /subfolder/
Configuration: Windows Vista
6 réponses
Hello Nono313
Try with:
move "source_folder_name" "destination_folder_name"
while omitting the asterisk intended to replace the file names but don't forget to include the " if your folder names contain spaces.
Have a good evening.
JF
Try with:
move "source_folder_name" "destination_folder_name"
while omitting the asterisk intended to replace the file names but don't forget to include the " if your folder names contain spaces.
Have a good evening.
JF
Thank you for your response
I tried
and
and it still doesn't work
I tried
move ".\Complete Downloads\" .\
and
move ".\Complete Downloads\" ".\"
and it still doesn't work
Re-hello
Oops, I forgot, the "move" command only transfers one directory at a time... you would need to loop through the names of the directories and files located in the "Complete Downloads" directory
However, you can use the "xcopy" command which will allow you to transfer everything in one go
If I understand what you are trying to do, it's to move an entire directory tree up one level. If that's the case, from the destination directory, run the command
xcopy /F /E "Complete Downloads\*"
(help xcopy will allow you to see the available options with this command)
/F will display the files and directories copied
/E will also copy empty directories
This, however, has the downside that you will temporarily need more space on the disk.
The directory structure in the "Complete Downloads" directory can then be deleted with the command
rd /S /Q "Complete Downloads"
There you go, I hope I was able to help you.
Have a good evening.
JF
Oops, I forgot, the "move" command only transfers one directory at a time... you would need to loop through the names of the directories and files located in the "Complete Downloads" directory
However, you can use the "xcopy" command which will allow you to transfer everything in one go
If I understand what you are trying to do, it's to move an entire directory tree up one level. If that's the case, from the destination directory, run the command
xcopy /F /E "Complete Downloads\*"
(help xcopy will allow you to see the available options with this command)
/F will display the files and directories copied
/E will also copy empty directories
This, however, has the downside that you will temporarily need more space on the disk.
The directory structure in the "Complete Downloads" directory can then be deleted with the command
rd /S /Q "Complete Downloads"
There you go, I hope I was able to help you.
Have a good evening.
JF
Thank you for your reply, I can now copy the files and folders.
The problem is that the rd command also deletes the "Completed downloads" folder instead of just emptying it.
The problem is that the rd command also deletes the "Completed downloads" folder instead of just emptying it.
So the simplest way is to create a small batch file with the following code:
xcopy /F /E %1
rd /S /Q %1
md %1
You can name it "up.bat" and simply run it with
up "Complete downloads"
It will also allow you to go up other directories since %1 replaces the parameter you give to the up command.
Have a good evening.
JF
xcopy /F /E %1
rd /S /Q %1
md %1
You can name it "up.bat" and simply run it with
up "Complete downloads"
It will also allow you to go up other directories since %1 replaces the parameter you give to the up command.
Have a good evening.
JF