Announcement

Collapse
No announcement yet.

Copy Files an Rename Them in Sequence

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Copy Files an Rename Them in Sequence

    Hi

    I Have a button where users can attache files and these files goes a variable Folder depends on the episode they are working on, so i made the code to copy the selected file the specific folder.
    What i failed to do is to rename the files after they are copied to a sequence like (Doc1,Doc2,Doc3 ....etc) with keeping their extension since the file may contains images or docs.

    If the naming can follow the arrangement of selecting the files it will be great.

    Code:
    Files_Selected = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", true, false);
    
    if (Files_Selected[1] ~= "CANCEL") then
    
    
    DestFolder = _SourceFolder.."\\AutoPlay\\Docs\\"..Unit..EP
    
    for j in pairs (Files_Selected) do
    
    StatusDlg.Show(MB_ICONNONE, false);
    File.Copy(Files_Selected[j], DestFolder, true, true, false, true, nil);
    
    end
    
    error = Application.GetLastError();
    StatusDlg.Hide();
    
    
    if error ~= 0 then
    Dialog.Message("Error", "There was an error copying the files. Please try again.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
    else
    Dialog.Message("Congrats", "Files Are Successfuly Copied", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    end
    Thanks

  • #2
    Hi sameer valva
    Try This Example

    sameer.apz

    Cheers

    Comment


    • #3
      Hi colc
      Thank you so much for the project file , i will give a try today i return to you.

      Comment


      • #4
        colc Tested , Exactly what needed, Thanks

        Comment

        Working...
        X