| View previous topic :: View next topic |
| Author |
Message |
doyle
Joined: 14 Nov 2007 Posts: 325 Location: London, England
|
Posted: Mon Jun 08, 2009 12:23 pm Post subject: Move Files Script - How to get selected file info?? |
|
|
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 |
|
 |
JDN
Joined: 24 Mar 2004 Posts: 299
|
Posted: Mon Jun 08, 2009 12:45 pm Post subject: |
|
|
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 |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
Posted: Mon Jun 08, 2009 12:47 pm Post subject: |
|
|
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 .
hth _________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞
Last edited by TLM on Mon Jun 08, 2009 12:53 pm; edited 2 times in total |
|
| Back to top |
|
 |
doyle
Joined: 14 Nov 2007 Posts: 325 Location: London, England
|
Posted: Mon Jun 08, 2009 12:48 pm Post subject: |
|
|
| 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 |
|
 |
doyle
Joined: 14 Nov 2007 Posts: 325 Location: London, England
|
Posted: Mon Jun 08, 2009 12:54 pm Post subject: |
|
|
| 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 .
hth |
Thank you for the response.
I will give it a try.  |
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
Posted: Mon Jun 08, 2009 1:18 pm Post subject: |
|
|
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:
(Yes its just that line )
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 |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Mon Jun 08, 2009 2:10 pm Post subject: |
|
|
| 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 |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
|
| Back to top |
|
 |
doyle
Joined: 14 Nov 2007 Posts: 325 Location: London, England
|
Posted: Mon Jun 08, 2009 2:44 pm Post subject: |
|
|
| TLM wrote: | Figured copy was too obvious..  |
Same here.
Thank you both for your help.
I think I can probably get there now after this. |
|
| Back to top |
|
 |
doyle
Joined: 14 Nov 2007 Posts: 325 Location: London, England
|
Posted: Mon Jun 08, 2009 2:55 pm Post subject: |
|
|
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 |
|
 |
Z_Gecko Guest
|
Posted: Mon Jun 08, 2009 2:57 pm Post subject: |
|
|
| use FileExist(FilePattern) |
|
| Back to top |
|
 |
doyle
Joined: 14 Nov 2007 Posts: 325 Location: London, England
|
Posted: Mon Jun 08, 2009 3:15 pm Post subject: |
|
|
| Z_Gecko wrote: | | use FileExist(FilePattern) |
Awesome! Thank You! |
|
| Back to top |
|
 |
|