Forum Moderators: phranque

Message Too Old, No Replies

regex job. Newbie here.

Change working directory based on filetype.

         

pEhrlich

6:19 pm on Oct 27, 2007 (gmt 0)

10+ Year Member



Hi

I'm looking for a way to change the working directory (path) for a requested file based on its filetype. Something like: If file requested is filename.abc look for it in directory1/filename.abc, if file requested is filename.xyz look for it in directory2/filename.xyz, etc.

The filename could be anything. There would be dashes in it, I don't know if thats a problem. There should be a way to make conditions for four or five filetypes.

This doesn't seem to hard for someone who knows regexs but I'm at a loss even after a couple tuts. Whats a good way to learn?

Thanks!
--Peter

pEhrlich

10:10 pm on Oct 27, 2007 (gmt 0)

10+ Year Member



Hmm. A little more googling brings up [example in another forum]. I'll give it a shot in a bit.

[edited by: jdMorgan at 12:05 am (utc) on Oct. 28, 2007]
[edit reason] No URLs, please. See TOS. [/edit]

jdMorgan

12:07 am on Oct 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The solution to the looping problem posted in the discussion you found is potentially "non-optimal," since it will break the code that follows later.

Jim