 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
phatmankerr Guest
|
Posted: Tue Jun 21, 2005 11:37 am Post subject: FileMove Script |
|
|
Sorry am new to AHK, set up the following script that I thought would move files that met certain rules (in this case txt file) from one directory to another, but the script appears to do nothing ?
Any suggestions would be appreciated.
Thanks
phatman
file_it = Loop,E:\*.*,0,0
{
stringright, move_it, file_it,3
if (move_it="txt")
{
filemove, file_it, E:\Files\txt\
}
}
Return |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Tue Jun 21, 2005 12:11 pm Post subject: |
|
|
Loop, E:\*.txt, 0, 0
{
FileMove, %A_LoopFileFullPath%, E:\Files\txt
} |
|
| Back to top |
|
 |
phatmankerr Guest
|
Posted: Tue Jun 21, 2005 12:32 pm Post subject: Existing Files ? |
|
|
Bobo,
Excellent, thanks mate, is there a way to check if the file already exists in the target directory and if so append the current date to the file name and then move it ?
Thanks for your help
Phatman |
|
| Back to top |
|
 |
phatmankerr Guest
|
Posted: Tue Jun 21, 2005 12:35 pm Post subject: Exclude Certain file |
|
|
Bobo,
Sorry mate, am pushing it slightly, but I also need to exclude certain files from the Move Operation (e.g. if the file name starts with 'Schedule').
Thanks
Phatman |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Tue Jun 21, 2005 1:15 pm Post subject: |
|
|
| Code: | FileTypes = txt,doc,xls,mdb
StringSplit, FExt, FileTypes, `,
Loop, %FExt0%
{
FileExt := FExt%A_Index%
Loop, E:\*.%FileExt%, 0, 0
{
FileMove, %A_LoopFileFullPath%, E:\Files\%FileExt%
}
} |
|
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Tue Jun 21, 2005 1:23 pm Post subject: |
|
|
| Quote: | | Sorry mate, am pushing it slightly, but I also need to exclude certain files from the Move Operation (e.g. if the file name starts with 'Schedule'). |
| Code: | Loop, E:\*.%FileExt%, 0, 0
{
If A_LoopFileFullPath contains \Schedule,\Private,\BoBos
Break
FileMove, %A_LoopFileFullPath%, E:\Files\%FileExt%
} |
|
|
| Back to top |
|
 |
phatmankerr Guest
|
Posted: Tue Jun 21, 2005 1:52 pm Post subject: Additional Code |
|
|
Bobo,
Excellent, thanks for all your help mate.
Much appreciated
Phatman |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Tue Jun 21, 2005 5:43 pm Post subject: |
|
|
| Quote: | | is there a way to check if the file already exists in the target directory and if so append the current date to the file name and then move it ? | Yes.
| Code: |
FileTypes = txt,doc,xls,mdb
StringSplit, FExt, FileTypes, `,
Loop, %FExt0%
{
FileExt := FExt%A_Index%
Loop, E:\*.%FileExt%, 0, 0
{
SplitPath, A_LoopFileFullPath, OutFileName
If OutFileName contains Schedule,Private,BoBos
Break
IfFileExist, E:\Files\%FileExt%\%OutFileName%
OutFileName = %A_Now%_%OutFileName%
FileMove, %A_LoopFileFullPath%, E:\Files\%FileExt%\%OutFileName%
}
} | Of course, untested.   |
|
| Back to top |
|
 |
badcoder Guest
|
Posted: Wed Jan 04, 2006 7:19 pm Post subject: |
|
|
Hi folks !
| Code: | Loop, E:\*.txt, 0, 0
{
FileMove, %A_LoopFileFullPath%, E:\Files\txt
} |
How could I write the name of the txt file in a variable, that the loop function found, and send it for e.g. to 'run, test.exe %VarOutput%' ? The problem ist that the loop function runs again and again the test.exe. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri Jan 06, 2006 2:02 am Post subject: |
|
|
| I could use clarification. Do you want to launch test.exe for each text file in a certain directory, passing the name of each text file as a parameter? |
|
| Back to top |
|
 |
badcoder Guest
|
Posted: Fri Jan 06, 2006 3:42 pm Post subject: |
|
|
Hi !
My english is not that good, but I hope I understood you right.
Yes, I want to launch test.exe for each text file in a certain directory, , passing the name of each text file as a parameter. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri Jan 06, 2006 5:09 pm Post subject: |
|
|
I think this should do it.
| Code: | Loop E:\*.txt
Run test.exe "%A_LoopFileFullPath%" |
|
|
| Back to top |
|
 |
badcoder Guest
|
Posted: Fri Jan 06, 2006 5:59 pm Post subject: |
|
|
Hi !
Thanks for your quick answer !
You opened my eyes. I had used the variable 'A_LoopFileName' and forgotten that the file extension is included. Which variable have I to use that the file extion isn't included - I have searched the help file but doesn't found the right variable. Can you help ?
Thanks in advance
badcoder |
|
| Back to top |
|
 |
Decarlo110
Joined: 15 Dec 2004 Posts: 303 Location: United States
|
Posted: Fri Jan 06, 2006 6:13 pm Post subject: |
|
|
| Quote: | | Which variable have I to use that the file extion isn't included |
There is no built-in variable for that, but you could use:
| Code: | | StringTrimRight, var_trimmed, A_LoopFileFullPath, 4 |
_________________ 1) The Open Source Definition http://www.opensource.org/docs/definition_plain.php
2) Intuitive. Logical. Versatile. Adaptable. <<AutoHotkey>> |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Jan 06, 2006 6:35 pm Post subject: |
|
|
@ badcoder
StringSplit (not a variable, it's the AHK command which delivers it) ? That might be the reason why I've used it within my sample code above, which btw. you've tested ??? |
|
| 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
|