0

I'm trying to automatically move the subfolders and files from my Dropbox folder on my F: Drive to a separate folder on the same drive, therefore emptying my Dropbox and freeing up space in it while backing up the files.

I tried this in Batch:

MOVE /-Y "F:\Dropbox\files\camera" "F:\backup\Camera\"
pause

but I keep getting Access Denied even when running as Administrator.

I also tried this in VBS:

With CreateObject("Scripting.FileSystemObject")
.MoveFile "F:\Dropbox\files\camera*", "F:\backup\Camera\"
End With

but I only got Path Not Found from that.

So pretty much I'm a bit stumped, or overlooking something obvious, But basically I just want to make a small script in vbs or batch that allows me to move all the sub-folders and files from F:\Dropbox\files\camera\ to F:\backup\camera\ so I can set it as a scheduled task and let it run each day so that it empties my Dropbox folder(and therefore my Dropbox account) of all files and folders and backs them up.

Any help would be appreciated, I have already searched a number of different options and none seems to work specifically for my purpose.

Moon
  • 3
  • 3
  • 1
    I just want to clarify: you want to move the contents (files and subfolders) of the `camera` folder to ```F:\backup\Camera\```? – Gino Mempin Aug 08 '18 at 23:57
  • 2
    Possible duplicate of [Rename and Move Folders Using VB](https://stackoverflow.com/questions/6143421/rename-and-move-folders-using-vb) – Geert Bellekens Aug 09 '18 at 05:56
  • @GinoMempin Yea, a camera uploads a folder with all its videos and images to the /camera folder every day, its a timestamped folder so overwriting isnt an issue, os I want all the timestamped folders and subfolders/files in /camera/ to be moved periodically to /backup/camera/ – Moon Aug 09 '18 at 11:56

1 Answers1

0

I suggest using ROBOCOPY instead of MOVE.
I have a similar backup script that uses it.

See:
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy

@ECHO OFF

ROBOCOPY /E /MOVE "F:\Dropbox\files\camera" "F:\backup\Camera\" 
MKDIR "F:\Dropbox\files\camera"

Options:

/E    : Copy Subfolders, including Empty Subfolders.
/MOVE : Move files and dirs (delete from source after copying).

Because of the /MOVE switch, I need to re-create the source directory because ROBOCOPY moves it to the destination directory. ROBOCOPY, by default, will retry the operation if it fails. See the /R:n and /W:n options to customize it. Also, the command will print a lot of info messages to the terminal, but you can customize it using the ROBOCOPY's logging options (ex. /NJH, /NJS, etc).

For the "Access Denied" error, make sure that:

  • You have write access to the destination folder
    (Test by creating a batch file with just MKDIR "F:\backup\Camera\some_file.txt")
    (Test by creating a batch file with just MKDIR "F:\backup\Camera\some_folder")
  • The files being moved are not being used or opened anywhere prior to running the script
    (Ex. It's not opened in the Dropbox app.)
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
  • 1
    technically, `MKDIR "F:\backup\Camera\some_file.txt"` creates a *folder* named `some_file.txt`. To create a *file* to a (already existing) folder, use for example `break>"F:\backup\Camera\some_file.txt"` – Stephan Aug 10 '18 at 05:03
  • This seems to happen for some reason while running the above script, 2018/08/10 13:03:33 ERROR 123 (0x0000007B) Accessing Destination Directory F:\backup\Camera" \E \MOVE\ The filename, directory name, or volume label syntax is incorrect. – Moon Aug 10 '18 at 12:04
  • 1
    I think I fixed it by moving the switches to before the directory, so @ECHO OFF ROBOCOPY /E /MOVE "F:\Dropbox\files\camera" "F:\backup\Camera\" MKDIR "F:\Dropbox\files\camera" – Moon Aug 10 '18 at 12:22