 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
TheLeO
Joined: 11 Jun 2005 Posts: 264 Location: England ish
|
Posted: Wed Feb 10, 2010 1:50 pm Post subject: Move stuff and rename if file exists? |
|
|
Hello,
I'm a support enigneer, I connect to a lot of remote sytems and document the things I do. I create around 50-100 Screen shots daily.
Does anyone have a ready script which does
folder a < all screen shots are created in here
folder b < screen shots moved here to various folders.
syntax would be
ask name of new folder > %new folder%
moves all files from folder "a" to "folder b\%new folder%
While doing so, if the file name already exists, then paste with a new name, and it would include sub folders as well..?
Anyone got something like this?
Leo.
[Moved from Scripts & Functions forum. ~jaco0646] _________________ ::
I Have Spoken
:: |
|
| Back to top |
|
 |
OceanMachine
Joined: 15 Oct 2007 Posts: 780 Location: England
|
Posted: Wed Feb 10, 2010 5:34 pm Post subject: |
|
|
This is an adaptation of a script I posted earlier this morning - should hopefully do what you need?
| Code: | SetFormat, Integer, hex ; so that the return value of the function is a hex value to match MSDN
SourceFolder := "C:\source" ; change this to your default source folder
while (!DestFolder)
FileSelectFolder, DestFolder, *C:\destination,,Please select distination folder ; change this to be a sensible place
; for default top-level destination.
SourceFolder := RegExReplace(SourceFolder, "\\$") . "\*" ; Removes the trailing backslashes, if present. The * means
DestFolder := RegExReplace(DestFolder, "\\$") ; copy everything in the source folder
VarSetCapacity(SHFILEOP, 30, 0) ; set up SHFILEOPSTRUCT
NumPut(1, SHFILEOP, 4) ; wFunc = FO_MOVE
NumPut(&SourceFolder, SHFILEOP, 8) ; pFrom
NumPut(&DestFolder, SHFILEOP, 12) ; pTo
NumPut(3612, SHFILEOP, 16) ; fFlags (FOF_SILENT + FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR
; + FOF_NOCOPYSECURITYATTRIBS + FOF_NOERRORUI + FOF_RENAMEONCOLLISION = 3612)
; This will not show any progress or any errors while moving the files, but will automatically rename files on
; collision (i.e. if file already exists) to "Copy of <filename>"
If ( Result := DllCall("shell32.dll\SHFileOperation", "Int", &SHFILEOP) )
{
MsgBox, % "An error occurred moving the files. Return Value was """ . Result
. """.`n`nPlease see the error codes at the following link for the meaning of this:"
. "`nhttp://msdn.microsoft.com/en-us/library/bb762164%28VS.85%29.aspx"
}
Else
MsgBox, % "Files should have been moved successfully and inherited the destination folder's permissions."
Return |
[Edit: This thread should probably be in the Help forum, not here]
[Edit: thanks jaco] |
|
| Back to top |
|
 |
kenn
Joined: 11 Oct 2010 Posts: 288
|
Posted: Fri Dec 03, 2010 2:51 pm Post subject: |
|
|
| OceanMachine, I was looking for such a script, amazing stuff with AHK, thanks! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|