swstrau118 Posted July 4, 2013 Share Posted July 4, 2013 I am trying to copy folders from the C drive to a Network Drive and I also have to copy folders and place them in a backup folder - is this possible? I have the following code but it doesn't appear to be working. Any help would be great! DirCopy(@DesktopDir & "\TEST", @TempDir & "\MyTempDir", 1) DirMove(@TempDir & "\MyTempDir", [NETWORKPATH]\Backup - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1) Link to comment Share on other sites More sharing options...
orbs Posted July 4, 2013 Share Posted July 4, 2013 as your code colouring suggests, you have a syntax error, misuse of double-quotes, and possibly variable issues. what do you expect [NETWORKPATH] to be? it can't be a real network path. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
michaelslamet Posted July 4, 2013 Share Posted July 4, 2013 Hi, Yes, that is possible. What exactly do you type in the [NETWORKPATH] ? What is the code exactly in that line? Also, you dont need &"" at the end Link to comment Share on other sites More sharing options...
swstrau118 Posted July 4, 2013 Author Share Posted July 4, 2013 (edited) Hi, Yes, that is possible. What exactly do you type in the [NETWORKPATH] ? What is the code exactly in that line? Also, you dont need &"" at the end Here is the code for the [NETWORKPATH]: DirCopy(@DesktopDir & "\TEST", @TempDir & "\MyTempDir", 1) DirMove(@TempDir & "\MyTempDir", "P:\TEST\Backup - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1) It does require an authentication as well. Edited July 4, 2013 by swstrau118 Link to comment Share on other sites More sharing options...
orbs Posted July 4, 2013 Share Posted July 4, 2013 just put another double-quote in front of P:TESTBACKUP, and delete the &"" at the end after @MIN Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
swstrau118 Posted July 4, 2013 Author Share Posted July 4, 2013 just put another double-quote in front of P:TESTBACKUP, and delete the &"" at the end after @MIN Great that worked! If I have two folders Test1 and Test2 that I am copying from C drive to the Network drive. If those two files exist is it possible to write an "If" statement to say if this Test1 and Test2 exist - rename the old files (to Test1 - 2013-07-03 or something) Here is the code I have and I do not receive any errors it just doesn't work. DirCopy(@DesktopDir & "\TEST", "P:\TEST", 1) If FileExists("Test1") AND ("Test2") Then FileMove("P:\TEST", "P:\TEST - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1) EndIf Link to comment Share on other sites More sharing options...
orbs Posted July 4, 2013 Share Posted July 4, 2013 use full absolute paths in FileExists(), and the AND condition is like this: DirCopy(@DesktopDir & "\TEST", "P:\TEST", 1) If FileExists("P:\Test1") AND FileExists("P:\Test2") Then FileMove("P:\TEST", "P:\TEST - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1) EndIf also, your code will rename P:TEST only if both files exist, "P:Test1" and "P:Test2", it will not touch "P:Test1" or "P:Test2" Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
swstrau118 Posted July 4, 2013 Author Share Posted July 4, 2013 (edited) Hmm.. I ran it and nothing happens - I do not receive any errors though. I want to try to make it rename the Test1 and Test2 if those files already exist. Edited July 4, 2013 by swstrau118 Link to comment Share on other sites More sharing options...
swstrau118 Posted July 4, 2013 Author Share Posted July 4, 2013 I tried this code and I was able to get it to rename the Test1 folder name but it renames it as a File not a folder. Also it will not copy any of the data from the C drive, once the folder is "renamed" it seems to loose all of the text files in the previous version of the folder. Here is the code: DirCopy(@DesktopDir & "\TEST", "P:\TEST", 1) If FileExists("P:\TEST\Test1") Then FileMove("P:\TEST\Test1", "P:\TEST\Test1 - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1) EndIf Link to comment Share on other sites More sharing options...
orbs Posted July 4, 2013 Share Posted July 4, 2013 now you're on the right track. how about using DirMove instead of FileMove? Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
M4n0x Posted July 4, 2013 Share Posted July 4, 2013 (edited) Hello, Try : FileMove("P:\TEST\Test1\*.*", "P:\TEST\Test1 - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN & "\", 8) Edited July 4, 2013 by M4n0x Link to comment Share on other sites More sharing options...
Solution swstrau118 Posted July 4, 2013 Author Solution Share Posted July 4, 2013 Got it! that's very cool Thanks so much! DirCopy(@DesktopDir & "\TEST", "P:\TEST", 1) If FileExists("P:\TEST\Test1") Then DirMove("P:\TEST\", "P:\TEST\Test1 - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1) EndIf Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now