Jump to content

Send Event - change folder name in Windows


This topic is 4983 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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."

Link to comment
Share on other sites

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 by Guest
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 4983 days old. Please don't post here. Open a new topic instead.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.