AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Move Files Script - How to get selected file info??

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
doyle



Joined: 14 Nov 2007
Posts: 325
Location: London, England

PostPosted: Mon Jun 08, 2009 12:23 pm    Post subject: Move Files Script - How to get selected file info?? Reply with quote

Hey guys,

I am working on a script that will be able to move files to regularly used custom locations by right clicking. (like "Send To" but far more customisable and advanced.)

My question is this....

How do I get information about a file I have selected in Windows Explorer?

e.g I have selected the file I want to move... how do I return that info into ahk so it can move the file?

Cheers

J
Back to top
View user's profile Send private message Visit poster's website
JDN



Joined: 24 Mar 2004
Posts: 299

PostPosted: Mon Jun 08, 2009 12:45 pm    Post subject: Reply with quote

What kind of info is it that you need?

Is it info needed to move the file? Or do you want supplementary info such as the file attributes? (like Read-Only, System or Archive)?
Back to top
View user's profile Send private message
TLM



Joined: 21 Aug 2006
Posts: 2926
Location: The Shell

PostPosted: Mon Jun 08, 2009 12:47 pm    Post subject: Reply with quote

Depending on you OS you can use a shell command from the registry.

For XP the key to add to is HKEY_CLASSES_ROOT\*\shell\[COMMAND NAME] (ie The name you want to see when you right click a file)\command
and the value will be "[drive]:\[complied script location]" %1. (Include the quotes if your system does not use 8.3)

%1 will represent the filename as a the variable %1% in the script. You can then do use a loop to convert the 8.3 format to the fullpath with A_LoopFileFullPath.

That should get you on your way Wink.

hth
_________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞


Last edited by TLM on Mon Jun 08, 2009 12:53 pm; edited 2 times in total
Back to top
View user's profile Send private message
doyle



Joined: 14 Nov 2007
Posts: 325
Location: London, England

PostPosted: Mon Jun 08, 2009 12:48 pm    Post subject: Reply with quote

JDN wrote:
What kind of info is it that you need?

Is it info needed to move the file? Or do you want supplementary info such as the file attributes? (like Read-Only, System or Archive)?


The main information needed is the file path, so that I can get that info into AHK so it can then perform the move to whichever directory is selected.

I've tried searching, but couldnt find anything. Although im sure its probably been discussed before.
Back to top
View user's profile Send private message Visit poster's website
doyle



Joined: 14 Nov 2007
Posts: 325
Location: London, England

PostPosted: Mon Jun 08, 2009 12:54 pm    Post subject: Reply with quote

TLM wrote:
Depending on you OS you can use a shell command from the registry.

For XP the key to add to is HKEY_CLASSES_ROOT\*\shell\[COMMAND NAME] (ie The name you want to see when you right click a file)\command
and the value will be "[drive]:\[complied script location]" %1. (Include the quotes if your system does not use 8.3)

%1 will represent the filename as a the variable %1% in the script. You can then do use a loop to convert the 8.3 format to the fullpath with A_LoopFileFullPath.

That should get you on your way Wink.

hth


Thank you for the response.

I will give it a try. Cool
Back to top
View user's profile Send private message Visit poster's website
TLM



Joined: 21 Aug 2006
Posts: 2926
Location: The Shell

PostPosted: Mon Jun 08, 2009 1:18 pm    Post subject: Reply with quote

Just to clarify. You 1st create a key in the registry by using:

Code:
RegWrite, REG_SZ, HKCR, *\shell\Display File Name\Command, , "%A_Desktop%\Displayname.exe" "`%1"


When you run this, you should be able to right click on any file and see "Display File Name" in the context menu. It will not work yet until you create the target script.

Next create the script:

Code:
msgbox, %1%
(Yes its just that line Wink)

Save it to your desktop and then compile it to the name Displayname.exe (for this example).

Now when you right click a file and choose Display File Name, you should get a message box with the file name and location.

You can then adapt this to your liking.

Let me know if it works or if you need further instructions.
_________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞
Back to top
View user's profile Send private message
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Mon Jun 08, 2009 2:10 pm    Post subject: Reply with quote

doyle wrote:
The main information needed is the file path, so that I can get that info into AHK so it can then perform the move to whichever directory is selected.
Read the CLIPBOARD doc
Quote:
Files (such as those copied from an open Explorer window with Control-C) are considered to be text: They are auto-converted to their filenames (with full path) whenever Clipboard is referenced in the script. To extract the files one by one ...
http://www.autohotkey.com/docs/misc/Clipboard.htm
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
TLM



Joined: 21 Aug 2006
Posts: 2926
Location: The Shell

PostPosted: Mon Jun 08, 2009 2:30 pm    Post subject: Reply with quote

Figured copy was too obvious.. Embarassed
_________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞
Back to top
View user's profile Send private message
doyle



Joined: 14 Nov 2007
Posts: 325
Location: London, England

PostPosted: Mon Jun 08, 2009 2:44 pm    Post subject: Reply with quote

TLM wrote:
Figured copy was too obvious.. Embarassed


Same here. Laughing

Thank you both for your help.

I think I can probably get there now after this.
Back to top
View user's profile Send private message Visit poster's website
doyle



Joined: 14 Nov 2007
Posts: 325
Location: London, England

PostPosted: Mon Jun 08, 2009 2:55 pm    Post subject: Reply with quote

Is there an effective way of establishing whether the file copied is a file or a folder?

If its a folder i'll have to use FileMoveDir instead of FileMove.

Is using ErrorLevel the only way? (i.e if one fails do the other)
Back to top
View user's profile Send private message Visit poster's website
Z_Gecko
Guest





PostPosted: Mon Jun 08, 2009 2:57 pm    Post subject: Reply with quote

use FileExist(FilePattern)
Back to top
doyle



Joined: 14 Nov 2007
Posts: 325
Location: London, England

PostPosted: Mon Jun 08, 2009 3:15 pm    Post subject: Reply with quote

Z_Gecko wrote:
use FileExist(FilePattern)


Awesome! Thank You!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group