Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

FileCopy and FileMove



  • Please log in to reply
2 replies to this topic
lilygel
  • Members
  • 249 posts
  • Last active: May 26 2017 04:13 AM
  • Joined: 18 Feb 2015
f4::
Gui, New
Gui, +AlwaysOnTop
Gui, Show, h170 w250, Drag n Drop
return

GuiDropFiles:
Loop, parse, A_GuiEvent, `n

if A_LoopField contains N3250CL          ; sevens
    {
    FileCopy, %A_LoopField%, E:\Users\ki\Google Drive\セブンス
    FileMove, %A_LoopField%, F:\BATs\download scheduler\done
    Run, E:\Users\ki\Google Drive\セブンス
    }
else if A_LoopField contains N3726BT      ; legend
    {
    FileCopy, %A_LoopField%, E:\Users\ki\Google Drive\レジェンド
    FileMove, %A_LoopField%, F:\BATs\download scheduler\done
    Run, E:\Users\ki\Google Drive\レジェンド
    }
; and so on
; and so forth
return

So here's what I'm doing. I download text files to temporary folders. After I'm done with them, I would then move them to specific folders (in the code above, they are in Google Drive). However, there are times when the files get updated in the site, so I would download them again. Since the files automatically go into the temp folders, I would have to move them again too.

This is where I'm troubled with. I need additional code that will determine if the file already exists in the target directory, and if it does, I want that file to be moved to a folder (say, a folder named "TBO"), then the copy the updated file to the Google Drive folder.

I'm experiencing difficulty because I don't know how I can get just the file name, since A_LoopField contains the full path. And I do not want to use the overwrite flag because I want to keep record of the old version of the text doc.

If someone has a simpler approach, much better.


PS:
I noticed that when I drop multiple files which go to different folders, only one folder gets opened. Is there a way to open all the folders where the copied files go to?
Might need to write the code another way to simplify it. >.<

stanman
  • Members
  • 177 posts
  • Last active: Oct 10 2015 12:52 AM
  • Joined: 29 Apr 2004
✓  Best Answer
I don't know how I can get just the file name, since A_LoopField contains the full path.

 

Use the command SplitPath



lilygel
  • Members
  • 249 posts
  • Last active: May 26 2017 04:13 AM
  • Joined: 18 Feb 2015

Use the command SplitPath


Awesome. I made a quick test script and ran into a bit of trouble, but I got it somehow to work. I'll post the whole code later and maybe someone can simplify it for me because it's kinda messy. At least, it looks messy to me. lol

 

EDIT:

Never mind.  I think I'll just place the code in a separate file.  At the moment, it's part of my general script so it's a bit out of place.  Anyway, there seems to be no issue at the moment.  I'll just polish it slowly.  Maybe add some tooltips for notifications.