Jump to content


Photo

Sort Files In Folders By Type...


  • Please log in to reply
5 replies to this topic

#1 freaky_entertainment

freaky_entertainment

    GMC Member

  • GMC Member
  • 287 posts

Posted 05 July 2008 - 11:36 PM

Well some dude made that kind of script that sorts files to different folders like for example it can sort all MP3 files (*.mp3) in a folder with the given name (for example folder called "MP3 only") . I cant seem to find that script . Can anyone help me about it :) It was quite useful ... :chikin
  • 0

#2 celebraces

celebraces

    GMC Member

  • GMC Member
  • 956 posts

Posted 06 July 2008 - 10:13 AM

Replace .mp3 with whatever extension you want to look for.
file_find_first("C:\your\directory\here\*.mp3",0)
Was that it or was there more to it?
  • 0

#3 Pacninja

Pacninja

    GMC Member

  • New Member
  • 100 posts

Posted 06 July 2008 - 01:14 PM

Actually, this script isn't too complicated, first off, you want to search for a certain format e.g.MP3

So, as celebraces has said, you would use file_find_first but you would set the path to your desired folder and specify your format with a *.FORMAT as this would find them all.
After this we would store the files into an array for easy identification.

Add this code into a script and execute the script via an object with the file folder and argument of the format you desire eg scr_sort("unsorted_folder","mp3","Destination_Folder")

f=file_find_first(working_directory+"\"+argument0+"\*."+argument1,"")
for(i=0;f!="";i+=1){
files[i]=f
f=file_find_next()
}

/*After we have listed all the files of a format we need to move them, so we take all the members of the array and copy them to a new folder.*/
for(j=0;j<i;j+=1){
file_rename(files[j],working_directory+"\"+argument2+"\"+string(i)+"."+argument1)
file_delete(files[j])
}

Edited by Pacninja, 06 July 2008 - 06:46 PM.

  • 0

#4 freaky_entertainment

freaky_entertainment

    GMC Member

  • GMC Member
  • 287 posts

Posted 06 July 2008 - 08:09 PM

Actually, this script isn't too complicated, first off, you want to search for a certain format e.g.MP3

So, as celebraces has said, you would use file_find_first but you would set the path to your desired folder and specify your format with a *.FORMAT as this would find them all.
After this we would store the files into an array for easy identification.

Add this code into a script and execute the script via an object with the file folder and argument of the format you desire eg scr_sort("unsorted_folder","mp3","Destination_Folder")

f=file_find_first(working_directory+"\"+argument0+"\*."+argument1,"")
for(i=0;f!="";i+=1){
files[i]=f
f=file_find_next()
}

/*After we have listed all the files of a format we need to move them, so we take all the members of the array and copy them to a new folder.*/
for(j=0;j<i;j+=1){
file_rename(files[j],working_directory+"\"+argument2+"\"+string(i)+"."+argument1)
file_delete(files[j])
}

doesnt seem to work ... and the script I've seen was a lot bigger though ...
  • 0

#5 Pacninja

Pacninja

    GMC Member

  • New Member
  • 100 posts

Posted 07 July 2008 - 02:52 PM

I have created a revised version which uses a batch file!
Download
  • 0

#6 freaky_entertainment

freaky_entertainment

    GMC Member

  • GMC Member
  • 287 posts

Posted 07 July 2008 - 04:37 PM

I am still using .gm6 files . GM7 ... just dont like it so I got rid of it . Anyway the thing I was talking about was not with separate file (like the batch file here) . It was just a script , which I use to sort file for example if I make it sort all files in "D:" and make it sort like for example ".jpg" files it will create a folder called "JPG" and put all the .jpg files in that folder . (Yes I know how to make a folder and get list of files with GM with file_find_first... etc I aint retarded , I just cant make a script that would sort files that way) :)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users