locked
File System - auto-rename duplicate file names by adding 1,2,3...at the end when moving files from one folder to the other using file system RRS feed

  • Question

  • I have a SSIS package to rename (ABC_123.pdf to ABC.pdf) and move files from one folder to the other. However, if there is already a file( ABC.pdf ) in the destination folder has the exact same name as a renamed file (ABC.pdf) in the original folder (maybe not same sizes), the renamed file won't move; or in my case, will be moved to \bad naming convention folder (I am using a SQL temp table to match old and new file names).

    Is there a way to move the file and auto change the renamed file name to ABC 1.pdf while moving? I don't want to add the time stamp.

    Thanks!

    Wednesday, May 10, 2017 9:38 PM

Answers

  • Hi JaneQ,

    Please check this similar thread that provide the details steps including code and check if it helps.

    Regards,

    Pirlo Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Pirlo Zhang Friday, May 26, 2017 7:47 AM
    • Marked as answer by JaneQ Wednesday, May 31, 2017 7:13 PM
    Friday, May 26, 2017 7:46 AM

All replies

    • Proposed as answer by Pirlo Zhang Monday, May 15, 2017 8:20 AM
    Wednesday, May 10, 2017 10:04 PM
  • Hi JaneQ,

    If you would like to move the original file to new dictionary and rename it if the original file has existed there. I'm afraid we can not use the File System Task to accomplish the requirement. File System Task allow we move and rename file or override the file but we can not rename it dynamically after comparing, it's not supported.

    To resolve the issue, I would suggest you to use the Script Task. Maybe you can use the File.exists() function to check if the file has existed, then write your code to rename your file (e.g. recurrence function) so that the file name is dynamic(ABC1.PDF,ABC2.PDF..)

    If you still have any questions, please feel free to ask.

    Best Regards,

    Pirlo Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Pirlo Zhang Monday, May 15, 2017 8:20 AM
    Friday, May 12, 2017 6:50 AM
  • Pirlo, thanks for your answer! Unfortunately, I am new and not familiar with the Visual Basic language. However, it is a good thought; I will definitely explore it in the future.
    Monday, May 15, 2017 4:35 PM
  • Hi JaneQ,

    Is there any updates here?

    Regards,

    Pirlo Zhang 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 22, 2017 8:32 AM
  • No. How about you? :)
    Wednesday, May 24, 2017 7:52 PM
  • Hi JaneQ,

    Please check this similar thread that provide the details steps including code and check if it helps.

    Regards,

    Pirlo Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Pirlo Zhang Friday, May 26, 2017 7:47 AM
    • Marked as answer by JaneQ Wednesday, May 31, 2017 7:13 PM
    Friday, May 26, 2017 7:46 AM