PDA

View Full Version : I need some help on this!



asdfarkangel
22-11-2011, 08:08 PM
Hi, this is not really a game related question. Thing is I don't really have much experience on pascal's file handling. I've got like a thousand mushrooms to study for my exam. They're on my computer with the species name as the file name. This makes it hard to practise because I deliberately look at the name of the file. I want a program that will run through the entire folder and rename every single file for example from 1-max. So then the file names would be 1.jpg 2.jpg 3.jpg etc... I don't think a program like this should be hard and I know that here there are people who can do something like this easily. I'd really appreciate it. Thanks, in advance.

Legolas
22-11-2011, 08:25 PM
Sorry for the reply not strictly related to your request, but you could try a spaced repetition (http://en.wikipedia.org/wiki/Spaced_repetition) system software like Anki (http://ankisrs.net/). Take my good wishes with you to the exam :)

SilverWarior
22-11-2011, 08:36 PM
All you need to do is recursivly search for matching files by using FindFirst and FindNext cals for searching files. You can find an example on next link: http://delphi.about.com/od/vclusing/a/findfile.htm
With that you fill up some string list (each filename is one string list item), and then you iterate trough stringlist items renaming the original files with RenameFile function. You can find an example on next link: http://delphi.about.com/od/delphitips2009/qt/delphi-rename-folder.htm
Now as you may have noticed above article explains of how to do folder renaming, the principle for renaming files is compleetly the same. When renaming files or folders don't forget about including proper file path ('C:\Some Folder\Some Subfolder\New Filename.ext" and not just "New Filename.ext") as NewFilename parameter of RenameFile function becouse in background the RenameFile actualy uses MoveFile functions wich is capable of moving files from one folder into another. This means that using just "New Filename.ext" would move your file unto current dir that your application is using wich might not be the same dir that the file originates from.

SilverWarior
22-11-2011, 08:48 PM
But if you just need a way for quickly changing filenames of multiple files and doesn't need to have a program capable of that you can just simply use windows explorer to do that for you. You do this by selecting multiple files and while they are selected pres F2 key wich is used to rename a file. This will start file renaimng proces of one of the selected files, similar as you would be renaming a single file. So now you just write the desired filename and press ENTER. Since you had more files selected windows explorer will automaticly add numbers on the end of your desired filename ('My FilenameX" where X is replaced by a number).
But if you are not using Windows i still think that other OS-es uses more or less similar proces on mas renaming of several files atonce.