• How To: for files

    IT Discussion
    9
    0 Votes
    9 Posts
    1k Views
    1

    @gjacobse said in How To: for files:

    That said, from what you are saying; is my ‘failure’ was omitting the /M which specifies the ‘searchmask’. And because of that omission, it didn’t have the comparative variable, and deleted everything.

    There were two things that tripped you up.

    The lack of /M to just find *.tmp files Using del *.tmp as the command

    First forfiles is a for-loop that executes whatever command you want for each file it finds.
    As @JasGot mentioned you will get one hit for each file it will find.

    With /D -15 you are specifying that you only want to find files older than 15 days.
    With /S you are telling forfiles to look in all subdirectories as well. You may or may not want that.
    With /M you can specify a filter which matching filenames you want to search for. Without /Mit will find all the files regardless if it's named 123.tmp or installation.txt

    Your initial command would find all files in all subdirectories regardless if it what name it had. That's why you needed /M.

    Secondly, forfiles will execute whatever command you want for each and every file it finds.
    Since your command was del *.tmp it would delete all tmp files every time it found a file.
    What you really wanted was to just delete the file it found.
    The @file will have the name of the file so del @file would only delete the file that was found.

  • 0 Votes
    8 Posts
    4k Views
    DustinB3403D

    I found the process I had used previously. Here it is here. Summarized below.

    Make sure the VM in question is shutdown.
    From the console xe vm-shutdown uuid=<UUID of Your VM> xe vbd-list vm-uuid=<UUID of Your VM> params=uuid,type xe vbd-destroy uuid=<UUID of Your CD/DVD> Of critical importance do not select Disk, ensure you select the UUID of the cd Repeat step 4 as many times as you have CD's that are unusable. Reboot the VM and add the device again.

    0_1470657322596_XenCenterMain_2016-08-08_07-55-01.png