Caveman_Nick Posted July 21, 2010 Share Posted July 21, 2010 I have a process that I am trying to create, and as part of the process I need to pick a folder name out of a path. More specifically I need to drop an item into a folder and capture the name of the parent folder (the folder I am dropping the item into) as output for use as a variable (to add as metadata, send an email, etc.) Anyone know of a script that might capture this data? Quote Link to comment Share on other sites More sharing options...
Ursa Majoris Posted July 21, 2010 Share Posted July 21, 2010 (edited) I have a process that I am trying to create, and as part of the process I need to pick a folder name out of a path. More specifically I need to drop an item into a folder and capture the name of the parent folder (the folder I am dropping the item into) as output for use as a variable (to add as metadata, send an email, etc.) Anyone know of a script that might capture this data? Could you pipe the output from the LS command to a parser and grab the bit you need from there? Caveat: I know very little about UNIX (did my UNIX admin class in 1995 and really haven't done much since) Edited July 21, 2010 by Ursa Majoris Quote Link to comment Share on other sites More sharing options...
Caveman_Nick Posted July 21, 2010 Author Share Posted July 21, 2010 Could you pipe the output from the LS command to a parser and grab the bit you need from there? Caveat: I know very little about UNIX (did my UNIX admin class in 1995 and really haven't done much since) Looking for an existing script that does what I am looking for...don't know much about scripting and can't find one with google. Maybe that would work, but I am not quite educated with it enough to say. Quote Link to comment Share on other sites More sharing options...
BiggieFries Posted July 21, 2010 Share Posted July 21, 2010 Do I have your procedure correct? You have a file. You have a path like this: /usr/local/caveman/nick/ You need to drop that file into: /usr/local/caveman/ Do you know the directory path beforehand? How will you be "dropping" it in? FTP, SCP, Something else? Is the file already on the file system? Quote Link to comment Share on other sites More sharing options...
Caveman_Nick Posted July 21, 2010 Author Share Posted July 21, 2010 Do I have your procedure correct? You have a file. You have a path like this: /usr/local/caveman/nick/ You need to drop that file into: /usr/local/caveman/ Do you know the directory path beforehand? How will you be "dropping" it in? FTP, SCP, Something else? Is the file already on the file system? I have a file. I want to drop that file into a directory. When I drop that file into the directory, I can use that as a trigger to run a defined action of sending a notification email out. I can hard code email addresses into my database so that the system knows who to email. That would make a bit of a mess in the administration area because of the number of different recipients. What I would prefer to do is name each folder with the email address of the recipient, and then have the action be able to pick this email address off of the folder name. In order to do so, I need to be able to capture the string in some reliable fashion. So, the directory structure would look like: /raid/jobs/Some_Client_Folder/Proof_Room/Client_Review/some_person@some_company.com/some_file.pdf When some_file.pdf gets dropped into the folder some_person@some_company.com, I want that action to trigger a script that will report the name of the folder (not the whole path) that the file was dropped into. Quote Link to comment Share on other sites More sharing options...
Ursa Majoris Posted July 21, 2010 Share Posted July 21, 2010 (edited) I have a file. I want to drop that file into a directory. When I drop that file into the directory, I can use that as a trigger to run a defined action of sending a notification email out. I can hard code email addresses into my database so that the system knows who to email. That would make a bit of a mess in the administration area because of the number of different recipients. What I would prefer to do is name each folder with the email address of the recipient, and then have the action be able to pick this email address off of the folder name. In order to do so, I need to be able to capture the string in some reliable fashion. So, the directory structure would look like: /raid/jobs/Some_Client_Folder/Proof_Room/Client_Review/some_person@some_company.com/some_file.pdf When some_file.pdf gets dropped into the folder some_person@some_company.com, I want that action to trigger a script that will report the name of the folder (not the whole path) that the file was dropped into. So at the risk of telling you what you already know and in the interests of clarity, you need a daemon that monitors the structure and when a file arrives, the daemon runs a short script that captures the folder name reading forwards from the last forward slash in the full path. Edited July 21, 2010 by Ursa Majoris Quote Link to comment Share on other sites More sharing options...
BiggieFries Posted July 21, 2010 Share Posted July 21, 2010 So at the risk of telling you what you already know and in the interests of clarity, you need a daemon that monitors the structure and when a file arrives, the daemon runs a short script that captures the folder name reading forwards from the last forward slash in the full path. Pretty much this. I doubt you'll find anything on the innertubes already made to do this but it should be fairly easy to create. If there are databases that need to be queried/other actions that need to be done by this script then it gets a little more complex. Quote Link to comment Share on other sites More sharing options...
Caveman_Nick Posted July 21, 2010 Author Share Posted July 21, 2010 So at the risk of telling you what you already know and in the interests of clarity, you need a daemon that monitors the structure and when a file arrives, the daemon runs a short script that captures the folder name reading forwards from the last forward slash in the full path. Pretty much this. I doubt you'll find anything on the innertubes already made to do this but it should be fairly easy to create. If there are databases that need to be queried/other actions that need to be done by this script then it gets a little more complex. I understand what I need....just looking for someone that knows how to do it. Nothing needs to be queried. I just need a script that will pick a folder name out of a path. I can work the rest. Quote Link to comment Share on other sites More sharing options...
westvirginia Posted July 21, 2010 Share Posted July 21, 2010 Nick - got this from the local db GOD here: If it’s a SQL database he can use the xp_cmdshell command to do just about all that stuff. Let me know if he’s on a Microsoft SQL database and I can give you more details. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.