1

The title pretty much says it all. My goal is to create some kind of file that can be executed by a double click (batch, for example) where I specify (in the file) the path to the folder that, does not need to be sent to the recycle bin, but have its CONTENTS sent to the recycle bin. See, I'm doing this for a Rainmeter skin. I have a lot of temporary files and folder created by Adobe, and I can control where they're placed at. However, there can be quite a few of them that stack up inside the folder I told them to be in, so I need find some way to create a file that will recycle all of the files and folders within the specified folder (but not recycling or deleting the specified folder). This way, the specified folder will still exist so that I don't have to make a new folder and force Premiere Pro to relocate to a new folder (in the instance that I delete the folder containing the files needing to be deleted, which I've already figured out how to do) each time that I use this script.

I've tried a utility called "Recycle.exe" but I can only figure out how to get it to recycle the specified folder rather than recycle its contents. For example, when I try the following in a batch file (when using the following utility: http://www.maddogsw.com/cmdutils/):

@echo off
Recycle D:\TestFolder
pause

This will send the folder named "TestFolder" to the Recycle Bin, as well as its contents (the same way they'd be sent to the recycle bin if you just did it normally). My goal is to keep the specified folder intact, still existing, but having ALL of its contents, not deleted, but sent to the Recycle Bin. I've tried numerous things but have been unsuccessful. I don't really care what it takes to achieve this, but the final product has to result in a file that can be double clicked and send the contents of the specified folder to the Recycle Bin. VBS and Batch files were just examples, but I'm sure that there might be other ways to do it. I really need your help because I'm extremely close on this one.

(Also, please don't ask why I'm sending it to the Recycle Bin instead of deleting it, I'm doing it simply for the safety in case I determine that I need to restore the media cache/preview files. Keep in mind that sending the contents of the folder to the Recycle Bin instead of deleting them is an utter crucial function that I'm looking to accomplish with this, however.)

  • Can you run recycle.exe on files, or does the parameter require a folder? – SomethingDark Feb 14 '15 at 01:37
  • You can use it on files as well. However, you have to specify the files directly (by using the directory/path to the file). It is also capable of recycling multiple files and folders at once, but the problem is that they have to be specified. That's not something that I can work with when Adobe creates Media Cache files that have names that change all the time (some of which are based upon the date of creation, etc). This is why my goal is to recycle the contents of a specified folder so that the aforementioned problem is nonexistent. – Laughable Junnyzup Feb 14 '15 at 01:48

1 Answers1

2

Since you can specify files and have a predetermined folder where you're keeping them, you can use a for loop to iterate through the list of files in the directory.

pushd D:\TestFolder
for /F %%A in ('dir /b') do Recycle %%A
popd

You may want to say echo Recycle %%A first to make sure it's going to grab everything you want.

The documentation for recycle.exe claims you can use wildcards, so in theory you could simply say recycle D:\TestFolder\*.* instead of using a for loop.

Whymarrh
  • 13,139
  • 14
  • 57
  • 108
SomethingDark
  • 13,229
  • 5
  • 50
  • 55
  • You were correct. This was all it took, and it was successful. I wasn't sure what wildcard originally referred to, but it's working flawlessly now. This is the code that worked: echo Recycle %%A recycle L:\Testin\*.* pause – Laughable Junnyzup Feb 14 '15 at 03:50
  • Here's a link for information regarding wildcards (there are others for other programs, these are just Windows/DOS wildcards). https://technet.microsoft.com/en-us/library/bb490639.aspx – user4317867 Feb 17 '15 at 03:49