Author Topic: Finding file names in a Project  (Read 7408 times)

Bandersnatch

  • Community Member
  • Posts: 7
  • Hero Points: 0
Finding file names in a Project
« on: January 19, 2007, 04:36:42 PM »
Hey again,

Now I'm trying to get all the filenames in the open project, but I'm having trouble finding a function or series of functions to do that.  I fist tried opening the project file and getting the filenames by parsing, but it concatenated the path names.  I also looked through the source code for both the projects form and the projects property form, but didn't see anything that particularly stood out.

The format I'm trying to get is the full path names, so I can run them with a batch file.

Any suggestions?
« Last Edit: January 19, 2007, 04:39:25 PM by Bandersnatch »

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Finding file names in a Project
« Reply #1 on: January 19, 2007, 04:43:14 PM »
Have a look at projutil.e - project_load()

HS2

Bandersnatch

  • Community Member
  • Posts: 7
  • Hero Points: 0
Re: Finding file names in a Project
« Reply #2 on: January 19, 2007, 06:19:47 PM »
While I was looking, I found the function 'absolute,' which fixed the concatenation problem I was having.  That's alot for the point in the right direction!

 :)

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
Re: Finding file names in a Project
« Reply #3 on: January 19, 2007, 10:16:43 PM »
Hey again,

Now I'm trying to get all the filenames in the open project, but I'm having trouble finding a function or series of functions to do that.  I fist tried opening the project file and getting the filenames by parsing, but it concatenated the path names.  I also looked through the source code for both the projects form and the projects property form, but didn't see anything that particularly stood out.

The format I'm trying to get is the full path names, so I can run them with a batch file.

Any suggestions?

Graeme pointed this out to me and it is very helpful

You can reference each filename using this
for_each_buffer() // call any function for every file in the project



message("Finished preprocessing " strip_filename(p_buf_name,"PD"))   // displays current buffername/filename in SlickCmd Window
p_buf_name is the name of the active buffer (file), and strip_filename() lets you format it with/without the patch, extension, drive letter, etc..

Graeme

  • Senior Community Member
  • Posts: 2812
  • Hero Points: 347
Re: Finding file names in a Project
« Reply #4 on: January 19, 2007, 10:30:59 PM »
Quote
You can reference each filename using this
for_each_buffer() // call any function for every file in the project


Actually, for_each_buffer calls the function you give it for every open buffer, not for every file in the project, but of course if you have all the project files open then you get all project files.

Sometimes projects can contain files that are not actually editable files - you can add any files you like to a project so e.g. you might have a .doc file that's related to the project, for easy access, so I guess you need to check the extension before opening a project file too.

Graeme