Announcement

Collapse
No announcement yet.

Script to delete

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

  • Script to delete

    I currently use this script to copy items to users redirected desktops

    for /R O:\Groups\10-group_N\01-Pgroup_n\Desktop %a in (.) do copy c:\desktop\*.url %a

    The file actually copies twice- once into each of the directories

    \\server\share\Groups\10-group_name\01-Private_1\Desktop\user

    \\server\share\Groups\10-group_name\01-Private_1\Desktop\user\Desktop

    I need to delete the file in the 1st level dir
    \\server\share\Groups\10-group_name\01-Private_1\Desktop\user

    How can I reconfigure this script to delete (or at minimum rename) the instance of the shortcut in the 1st level
    (\\server\share\Groups\10-group_name\01-Private_1\Desktop\user)

  • #2
    Re: Script to delete

    sample,
    Code:
    @echo off
    
    :: clean-up old urls from *all* (sub)folders
    Setlocal enabledelayedexpansion
    FOR %%i IN ("c:\desktop\*.url") DO Set URLs=!URLs! "%%~nxi"
    For /R "O:\Groups\10-group_N\01-Pgroup_n\Desktop" %%a in (.) do (
       For %%d in (%URLs%) do If exist "%%a\%%~d" (
       Set _deletedfiles=!_deletedfiles! "%%a\%%~d"
       del "%%a\%%~d"))
    Endlocal & Set _deletedfiles=%_deletedfiles%
    
    
    :: copy urls to the correct subfolder
    For /d %%a in ("O:\Groups\10-group_N\01-Pgroup_n\Desktop\*.") do (
       If exist "%%a\desktop" (
       xcopy /y /c /q "c:\desktop\*.url" "%%a\Desktop\"))
    
    
    echo.
    echo.-------------------
    echo  Priorly DELETED:
    echo.-------------------
    For %%d in (%_deletedfiles%) do echo %%~d
    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: Script to delete

      Awsesome update to the script...

      10000 points!!

      Can you direct me to a good source for stepping through the logic?

      Thanks again
      J

      Comment

      Working...
      X