Arbatax Posted November 5, 2010 Posted November 5, 2010 Hi, I am having trouble creating a simple script step that changes a folder name. The code below does not seem to work: "cmd /k ren " & Quote("F:x") & " " & Quote("F:y") Any suggestions will be appreciated.
mleering Posted November 5, 2010 Posted November 5, 2010 Hello Arbatax; I'm not on Win 7 right on this computer, so things might be different on your OS... so, because of that, I'm sort of shooting in the dark. I will provide some generic advice too though, in case my accuracy is poor due to the darkness. Firstly, whenever I've run folder-level operations on Win XP from within FileMaker, I've typically used the: Send Event ["aevt"; "odoc"; "cmd /c"] instead of "/k". I would give that a try, and see if it yields any better success for you. Should that fail though, I would recommend adding some extra info to the end of your command to tell Windows to pipe its output into a file. ex. adding " > F:output.txt" to the end of it, should hopefully create a new file called output.txt on your F Drive, containing the results of Windows attempt at your requested operation. Hope this helps Matt
Arbatax Posted November 5, 2010 Author Posted November 5, 2010 Hi Matt, thanks a lot for your reply. The event fails to change the folder with either /c or /k. The difference is that if I use /k the shell window will stay open and give me the following feedback: "The syntax of the command is incorrect." I have added " > F:output.txt" to the command as you suggested. The relevant file is created in F:, but it's empty. If you have any further suggestions, I'd be glad to read them.
mleering Posted November 5, 2010 Posted November 5, 2010 The next thing that I would suggest then, would be to omit the drive/path from the second argument. Since the "ren" command cannot change the drive/path of the folder to be renamed, perhaps doing something like: "cmd /k ren " & Quote("H:x") & " " & "y" This worked for me. Hope it works for you too! Matt
Arbatax Posted November 5, 2010 Author Posted November 5, 2010 Thanks so much Matt, it worked! What I need to do next is make this script work on the user's desktop, so that "foldername" can be changed to a different value, preferably coming from a field. What I am trying now, without success, is the following: "cmd /k ren " & Quote( Right( Get(DesktopPath) ; Length(Get(DesktopPath)) - 1 ) & "foldername" & " " & "new_foldername") Again, the only feedback I receive from Windows is "The syntax of the command is incorrect."
Ted S Posted November 5, 2010 Posted November 5, 2010 (edited) I see you are using an H: drive. I assume that this means that you are trying to rename a folder that is on a different drive. I don't think that can be done directly. Try something like this: c: && cd && cd folderfolder && ren oldFolder newFolder The && characters allow multiple commands to be on one line. So in my example: C: (go to the C: drive) cd (go to the root of the C: drive) cd folderfolder (go in two folders) ren oldFolder newFolder (rename the old folder) I looks like you have the know how to make the syntax Filemakery. Good luck, let us know how it comes out. Edited November 5, 2010 by Guest
Arbatax Posted November 5, 2010 Author Posted November 5, 2010 Hi Ted, thanks for replying. No, I am not using a different drive than C:. In the example above I used another drive because I wanted to avoid any possible permission issues with the root level of the C: drive. But C: is the main drive on the system I am using and it's the drive that appears by default when I open a command-line shell. Also, I thought the Get(DesktopPath) function I am using here should take care of inserting the user's desktop into the command that I am trying to pass. Thanks for any further comments or suggestions.
mleering Posted November 5, 2010 Posted November 5, 2010 Hey Arbatax; a couple of minor changes to what you're doing. These changes are because both arguments were enclosed wtihin your Quote() function The slashes from Get (DesktopPath) need to be reversed to use on the Windows OS "cmd /k ren " & Substitute (Quote( Right( Get(DesktopPath) ; Length(Get(DesktopPath)) - 1 ) & "foldername" ) ; "/" ; "" ) & " " & "new_foldername"
Ted S Posted November 5, 2010 Posted November 5, 2010 Can you get it to work directly from a command prompt or do you get the error there as well?
Cabinetman Posted November 5, 2010 Posted November 5, 2010 this works for me on Vista.......... I realize it isn't /k ... but I'm a layman so..... "cmd /c ren "" & Right( Get(DesktopPath) ; Length(Get(DesktopPath)) - 1 ) & table::foldername & """ & " " & table::newfoldername
Arbatax Posted November 5, 2010 Author Posted November 5, 2010 Hi Cabinetman, it worked, thank you! For testing purposes I replaced the field names with strings "foldername" and "newfoldername" and I had no problem. I think /k is actually useful while testing the script as it leaves the shell window open and lets you see the error, if any. I will now change it to /c. Thank you very much to everyone who replied, as each single answer proved to be useful in one way or another.
Cabinetman Posted November 5, 2010 Posted November 5, 2010 So can you explain it to me? LOL Seriously though... I can't take credit for it I went through this before on here... and worked on it... and worked on it for a bit until it finally worked for me.... There's a thread with it in here somewhere.
Arbatax Posted November 5, 2010 Author Posted November 5, 2010 did I talk to soon? Please bear with me... I have replaced the stings between quotes (which worked) to actual field names from my database and now Windows complains about incorrect syntax again. Here's what the current string looks like. "cmd /k ren "" & Right( Get(DesktopPath) ; Length(Get(DesktopPath)) - 1 ) & "samplejob" & """ & " " & ${jobs}::jobtitle Perhaps I'm doing something wrong with the quotes, but the above strings reflects Cabinetman's suggestion quite literally, I think.
Arbatax Posted November 5, 2010 Author Posted November 5, 2010 Wait, I think I got it! Here's the final string: "cmd /k ren "" & Right( Get(DesktopPath) ; Length(Get(DesktopPath)) - 1 ) & "samplejob" & """ & " " & Quote(${jobs}::jobtitle) The problem was that the jobtitle field can contain a long sequence of words, including spaces, so by using the Quote function I think I am taking care of that.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now