Jump to content

Recommended Posts

Posted

Hello All,

 

Ok so I am on windows 7 and I am trying to delete a file from a folder copy the remaining contents of that folder to its parent folder then remove the two folders in that parent folder. Here is the script I am using.

@echo OFF

del C:\Users\Public\Desktop\Parent folder\Baby-A\The file I want deleted.docx

copy C:\Users\Public\Desktop\Parent folder\Baby-A *.* C:\Users\Public\Desktop\Parent folder

rmdir C:\Users\Public\Desktop\Parent folder\Baby-A

rmdir C:\Users\Public\Desktop\Parent folder\Baby-B

pause

 

FYI- The files I want saved are shortcuts (not sure if that matters but I think it might) and the pause is only there for debugging purposes. Every time I try to run the script it says that the system cannot find the path specified even though I have verified their locations several times I can also browse to the specific folders using the CMD, but when I try to enter in "copy C:\Users\Public\Desktop\Parent folder\Baby-A *.* C:\Users\Public\Desktop\Parent folder" from C:\users\public\desktop\parent folder\Baby-A it says file not found. Please help!! Thank you for taking the time to read my question.

Posted

You need to add quotes around the paths that contain spaces.

 

@echo off 
del "C:\Users\Public\Desktop\Parent folder\Baby-A\The file I want deleted.docx"
copy "C:\Users\Public\Desktop\Parent folder\Baby-A\*.*" "C:\Users\Public\Desktop\Parent folder"
rmdir "C:\Users\Public\Desktop\Parent folder\Baby-A"
rmdir "C:\Users\Public\Desktop\Parent folder\Baby-B"
pause

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...