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 

FileMove Script
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
phatmankerr
Guest





PostPosted: Tue Jun 21, 2005 11:37 am    Post subject: FileMove Script Reply with quote

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





PostPosted: Tue Jun 21, 2005 12:11 pm    Post subject: Reply with quote

Loop, E:\*.txt, 0, 0
{
FileMove, %A_LoopFileFullPath%, E:\Files\txt
}
Back to top
phatmankerr
Guest





PostPosted: Tue Jun 21, 2005 12:32 pm    Post subject: Existing Files ? Reply with quote

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





PostPosted: Tue Jun 21, 2005 12:35 pm    Post subject: Exclude Certain file Reply with quote

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





PostPosted: Tue Jun 21, 2005 1:15 pm    Post subject: Reply with quote

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





PostPosted: Tue Jun 21, 2005 1:23 pm    Post subject: Reply with quote

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





PostPosted: Tue Jun 21, 2005 1:52 pm    Post subject: Additional Code Reply with quote

Bobo,

Excellent, thanks for all your help mate.

Much appreciated

Phatman
Back to top
BoBo
Guest





PostPosted: Tue Jun 21, 2005 5:43 pm    Post subject: Reply with quote

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. Cool

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. Rolling EyesWink
Back to top
badcoder
Guest





PostPosted: Wed Jan 04, 2006 7:19 pm    Post subject: Reply with quote

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

PostPosted: Fri Jan 06, 2006 2:02 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
badcoder
Guest





PostPosted: Fri Jan 06, 2006 3:42 pm    Post subject: Reply with quote

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

PostPosted: Fri Jan 06, 2006 5:09 pm    Post subject: Reply with quote

I think this should do it.
Code:
Loop E:\*.txt
    Run test.exe "%A_LoopFileFullPath%"
Back to top
View user's profile Send private message Send e-mail
badcoder
Guest





PostPosted: Fri Jan 06, 2006 5:59 pm    Post subject: Reply with quote

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

PostPosted: Fri Jan 06, 2006 6:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
BoBo
Guest





PostPosted: Fri Jan 06, 2006 6:35 pm    Post subject: Reply with quote

@ 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
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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