5 Replies Latest reply on Apr 17, 2015 10:10 PM by christopherc

    Unable to Rename a Windows file with Send Event

    christopherc

      Title

      Unable to Rename a Windows file with Send Event

      Post

      I am trying to rename a file using the Send Event script command with no success. I first tried using variables in the calculation.

      Set Variable [$old; Value:"d:\Import.log"]

      Set Variable [$new; value:"Export.log"]

      For the Send Event Calculation I entered:

      "cmd /c rename " & quote($old) & " " & quote($new)

      When that didn't work I stripped it down to a basic command with no variables for testing. In the Send Event calculation box I entered:

      "cmd /c rename d:\Import.log Export.log"

      I could not get that to work either. 

      If I open a Windows command prompt and enter "rename d:\Import.log Export.log" (without the quotes) it works fine. I've use the Send Event command to create folders successfully, but have had no luck with renaming files. Ultimately I would like to rename folders. Am I missing something obvious?

       

        • 1. Re: Unable to Rename a Windows file with Send Event
          TKnTexas

          I am looking to rename files as well.  The only failure I saw as a caveat was if their is an existing file with the target name, it will fail.

          The other thing different in what I am doing, I have a batch file that I am calling.  I do not think the CMD is needed.  But I could be wrong on that.

          • 2. Re: Unable to Rename a Windows file with Send Event
            christopherc

            I created a batch file with the command "rename d:\import.log export.log", ran it in a Windows command prompt window, and it worked fine. I then inserted the path of the batch file into a Send Event command  - "d:\christopher\documents\dropbox\rename.bat" (without preceding it with "cmd") and that was also successful. I then copied the command from the batch file, preceded it with "cmd" and inserted that into the Send Event ("cmd rename d:\import.log export.log"). That did NOT work. I want to create a Send Event command using variables for the file names so do not want to use a batch file for this. What am I doing wrong?

            • 3. Re: Unable to Rename a Windows file with Send Event
              philmodjunk

              One method that I have used for creating and running a batch file from Filemaker is to set up the command lines of the batch files as text in FileMaker text fields of a set of records. I then used Export Records to both export the file to the temporary folder and to also open the file--which then ran the batch file.

              This allowed me to use a script to modify the command line contents just before export.

              • 4. Re: Unable to Rename a Windows file with Send Event
                christopherc

                Thanks PhilModJunk - I really like that idea.It first of all solves my existing problem, and it also opens the door to a number of possibilities for managing files and folders on my hard drive, especially where multiple commands would be required. Very clever - thank you!

                • 5. Re: Unable to Rename a Windows file with Send Event
                  christopherc

                  I was successful using a text field in a records to create command lines for a batch file,  and then export the records. Initially it did not work. I changed the default Output File Character Set  Unicode (UTF16) in the 'Specify Export Order' window  to ASCII (DOS) and that fixed the problem.