Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Send Event - change folder name in Windows

Featured Replies

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.

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

  • Author

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.

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

  • Author

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

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

  • Author

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.

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"

Can you get it to work directly from a command prompt or do you get the error there as well?

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

  • Author

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.

Glad you got it working!

:

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.

  • Author

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.

  • Author

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.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.