Sign in to follow this  
Followers 0
hydrael

trying to make a script that ckecks a file, create folder from the filename, move the file in the folder

5 posts in this topic

first of all sorry for my english, and sorry i am not very specific

for my tries, but i can barely write in english.

Here is the situation

I am trying to sort my ebooks collection which is like, 50000 files

in the same folder.

Their filename is like that

Author_book title

" what i want is to make a script that checks the filename and

takes the "Author" part of the filename and moves the file

in a folder name "Author""

i believe i can do that using a filelist, a txt, and a million "send keystrokes"

to create a bat file that does that. I have done something similar in the past, in a similar

situation, but this is probably the most inefficient way possible.

Can anyone help me?

Only coding experience i have is some C.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Look at _FileListToArray in the Help. It reads the contents of a directory. From there you can use DirCreate, FileCopy/FileMove. Forget about sending keystrokes. Also look at StringInStr to find the location of the underscore (the end of the author name). Spend some time in the Help files and I think you will find you will be able to complete your task with AutoIT without sending bunches of keystrokes..

Read files

Extract Autor for first file

Look for directory for the Author

- create teh directory if needed

Move all files for the author using wildcard

Something like that...

Edited by ctyankeeinok

Share this post


Link to post
Share on other sites

Thanks a lot for the fast response.

now that i know the correct functions i will try to make it...

Share this post


Link to post
Share on other sites

Made it, Thanks again

#Include <File.au3>
 #Include <Array.au3>
 Dim $var1
 $FileList=_FileListToArray(@WorkingDir)
 _ArrayDisplay($FileList,"$FileList")
  If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit 
        EndIf    
For $1=1 to $filelist[0] step 1 
$var1=StringInStr($FileList[$1]," - ")-1 
$path=stringleft($FileList[$1],$var1) 
$file=$FileList[$1] 
Filemove(@WorkingDir & "\" & $file, @WorkingDir &"\"& $path & "\", 9) 
Next

Share this post


Link to post
Share on other sites

Nice work. short to the point code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0