Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
May 18th 10AM ET, Live Chat, bring your QlikView questions. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
dsharmaqv
Creator III
Creator III

Rename and move files using exe command

Hi

I have a requirement to rename all the files present in the folder by appending date to actual file name and move it to archive folder.

Can any one help me in achiving the functonality by using exe command.

Many thanks in advance!

Deepak

1 Solution

Accepted Solutions
tamilarasu

Try this,


Let vSource = 'C:\Users\XXX\Desktop\ABC Dashboard\01SourceFile;
Let vArchive = 'C:\Users\XXX\Desktop\ABC Dashboard\01SourceFile\Archive';


For Each vFile in FileList('$(vSource)\*.*')

Let vNewFile = Replace(Subfield('$(vFile)','\','-1'),'.' & Subfield('$(vFile)','.','-1'), Date(Today(),'YYYYMMDD') & '.' & Subfield('$(vFile)','.','-1'));

EXECUTE cmd.exe /c Ren "$(vFile)" "$(vNewFile)";

NEXT;

EXECUTE cmd.exe /c Move /Y "$(vSource)\*" "$(vArchive)"
;

View solution in original post

3 Replies
sibin_jacob
Creator III
Creator III

You can use this command

cd /home/webapps/project1/folder1
for f in *.csv
do
  cp
-v "$f" /home/webapps/project1/folder2/"${f%.csv}"$(date +%m%d%y).csv
done

dsharmaqv
Creator III
Creator III
Author

Hi

Thanks for your reply.

I am trying below for moving files, dont know how to rename and then move.

FOR each vFile in filelist('C:\Users\XXX\Desktop\ABC Dashboard\01SourceFile\*')


LET File = 'C:\Users\XXX\Desktop\ABC Dashboard\01SourceFile\*';
Let AFile = 'C:\Users\XXX\Desktop\ABC Dashboard\01SourceFile\Archive\';

Execute cmd.exe /C move /Y "$(File)" "$(AFile)";

NEXT 

tamilarasu

Try this,


Let vSource = 'C:\Users\XXX\Desktop\ABC Dashboard\01SourceFile;
Let vArchive = 'C:\Users\XXX\Desktop\ABC Dashboard\01SourceFile\Archive';


For Each vFile in FileList('$(vSource)\*.*')

Let vNewFile = Replace(Subfield('$(vFile)','\','-1'),'.' & Subfield('$(vFile)','.','-1'), Date(Today(),'YYYYMMDD') & '.' & Subfield('$(vFile)','.','-1'));

EXECUTE cmd.exe /c Ren "$(vFile)" "$(vNewFile)";

NEXT;

EXECUTE cmd.exe /c Move /Y "$(vSource)\*" "$(vArchive)"
;

View solution in original post