hi ,
I have a csv file as job and by reading this file I am navigating to local directory .I need to rename the files based on content of csv file .
I am using switch scripter for reading the csv file .
Is there any option to rename the file on local disk using switch javascript.
Rename file in local directory
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Rename file in local directory
Switch only has copy() and remove() functions. You could use the system() function to call OS move/mv command.
var oldName = job.getPath();
var newName = job.createPathWithName("NewName");
s.copy(oldName, newName);
File.remove(oldName);
var oldName = job.getPath();
var newName = job.createPathWithName("NewName");
s.copy(oldName, newName);
File.remove(oldName);
-
- Newbie
- Posts: 9
- Joined: Tue Mar 18, 2014 3:17 pm
Rename file in local directory
HI ,
This is not working as the file that I want to rename is not a input job . I need to rename a file which is placed in local drive and not comming from job.
What I tried is
var fbxCompletePath = "E:Pradeeptest.fbx" ;
var newJob = s.createNewJob(fbxCompletePath);
var oldFileName = newJob.getPath();
var newName = E:Pradeepsuccess.fbx ;
var newFileName = job.createPathWithName(newName);
s.copy(oldFileName , newFileName);
but this is not working .
Please help
This is not working as the file that I want to rename is not a input job . I need to rename a file which is placed in local drive and not comming from job.
What I tried is
var fbxCompletePath = "E:Pradeeptest.fbx" ;
var newJob = s.createNewJob(fbxCompletePath);
var oldFileName = newJob.getPath();
var newName = E:Pradeepsuccess.fbx ;
var newFileName = job.createPathWithName(newName);
s.copy(oldFileName , newFileName);
but this is not working .
Please help
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Rename file in local directory
If you just want to copy a file somewhere
s.copy("E:Pradeeptest.fbx", "E:Pradeepsuccess.fbx");
To move it
s.copy("E:Pradeeptest.fbx", "E:Pradeepsuccess.fbx");
File.remove("E:Pradeeptest.fbx");
A backslash in a string needs to be quoted.
s.copy("E:Pradeeptest.fbx", "E:Pradeepsuccess.fbx");
To move it
s.copy("E:Pradeeptest.fbx", "E:Pradeepsuccess.fbx");
File.remove("E:Pradeeptest.fbx");
A backslash in a string needs to be quoted.
-
- Newbie
- Posts: 9
- Joined: Tue Mar 18, 2014 3:17 pm
Rename file in local directory
Thanks . It's working .