SCRIPT to Copy a file to another folder and if the name file has the same name, rename it RRS feed

  • General discussion

  • I have this script that Works very well, but, some users have some .pst with the same name, I dont want to overwrite it, what I need is, how can I rename the files during the process, or before.. after the process. Thank you

    rem Copia de Archivos PST a Carpeta FronMig*****
    @echo off
    taskkill /IM outlook.exe
    if not exist c:\FronMig mkdir c:\FronMig
    if not exist c:\FronMig\pst mkdir c:\FronMig\pst
    dir /b c:\*.pst /s > c:\FronMig\pathdata.txt
    for /f "tokens=1 delims=" %%a in (c:\FronMig\pathdata.txt) do (copy "%%a" c:\FronMig\pst) 
    start outlook.exe
    • Changed type Bill_Stewart Friday, July 7, 2017 6:37 PM
    • Moved by Bill_Stewart Friday, July 7, 2017 6:37 PM User should not be doing this
    Tuesday, May 23, 2017 4:46 PM

All replies

  • Please read the following:

    This forum is for scripting questions rather than script requests

    -- Bill Stewart [Bill_Stewart]

    Tuesday, May 23, 2017 10:13 PM
  • I'd suggest using PowerShell for that - it's actually a good small task to learn the basics of PowerShell with.

    To achieve what you want with PowerShell, you will want to use Test-Path cmdlet and different next step based on true/false outcome of this.

    Wednesday, May 24, 2017 9:58 AM
  • In addition, I would note that is is inadvisable to terminate the outlook.exe process (rather than asking it to close). This can lead to pst file corruption, which would run counter to the apparent purpose of the script.

    -- Bill Stewart [Bill_Stewart]

    Wednesday, May 24, 2017 2:12 PM