Question regarding Copy or Rename files

Question regarding Copy or Rename files

Postby Fech.G » Fri Nov 11, 2016 8:47 am

Hello Mahmoud,

First of all, I would say thank you for providing PWCT and answer our questions.

Then, question:

I'm currently intending to revise my first tool to add one function to rename files.

I found there are related functions but unfortunately I cannot use variable as file name.

Please see below steps tree extracted from a simple test file:
---------------------------------------------------------------------------------------------
The First Step
Define New Window ( win1 ) , Title : "Welcome to PWCT"
Window Events
Window Properties
Window Controls
Define New Button ( btn2 ) , Caption : "rename "
Button Events
Event: ON CLICK : Action MyRename()
Button Properties
End Of Window
Activate window
Procedures
Define Procedure MyRename
Start Here
OldFilename = "12345.txt"
NewFilename = "54321.txt"
Set Current Folder : "d:\000"
Copy File OldFilename to NewFilename
End of Procedure
------------------------------------------------------------------------------------------------------

If I input the file name (e.g. 12345.txt and 54321.txt) directly, It works fine. But it doesn't work if I use predefined variables as file name.

The error message shows Dos error 2, I got the point from google that the program cannot find the file from current folder.

I believe that it works, but could you please help to explain how to make it working for my case?

thanks a lot.
Fech.G
 
Posts: 3
Joined: Thu Dec 10, 2015 8:45 am

Re: Question regarding Copy or Rename files

Postby Mahmoud Fayed » Mon Dec 12, 2016 2:20 am

Hello Fech.G

Use the & operator before the variable name.

Another method is to use the Call Function component
Then type : run as the function name
Then type the command as parameters

So we have run("command is here")
example :
run("dir")
run("copy file1 file2")

In the string of the command, You can use any command, any variables as you want.

Greetings,
Mahmoud
Mahmoud Fayed
Site Admin
 
Posts: 642
Joined: Tue Apr 23, 2013 4:50 am


Return to Questions

Who is online

Users browsing this forum: No registered users and 0 guests

cron