AutoHotkey Community

It is currently May 26th, 2012, 5:13 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: FileMove Script
PostPosted: June 21st, 2005, 11:37 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 21st, 2005, 12:11 pm 
Loop, E:\*.txt, 0, 0
{
FileMove, %A_LoopFileFullPath%, E:\Files\txt
}


Report this post
Top
  
Reply with quote  
 Post subject: Existing Files ?
PostPosted: June 21st, 2005, 12:32 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: Exclude Certain file
PostPosted: June 21st, 2005, 12:35 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 21st, 2005, 1:15 pm 
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%
   }
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 21st, 2005, 1:23 pm 
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%
   }


Report this post
Top
  
Reply with quote  
 Post subject: Additional Code
PostPosted: June 21st, 2005, 1:52 pm 
Bobo,

Excellent, thanks for all your help mate.

Much appreciated

Phatman


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 21st, 2005, 5:43 pm 
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. 8)

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. :roll::wink:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 4th, 2006, 7:19 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2006, 2:02 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2006, 3:42 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2006, 5:09 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I think this should do it.
Code:
Loop E:\*.txt
    Run test.exe "%A_LoopFileFullPath%"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2006, 5:59 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2006, 6:13 pm 
Offline

Joined: December 15th, 2004, 10:24 pm
Posts: 303
Location: United States
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>>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2006, 6:35 pm 
@ 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 ???


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google Feedfetcher, Miguel, perlsmith, rbrtryn and 75 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group