# Folder clean up and unrar scripts v1.0

**URL:** <https://resource.dopus.com/t/folder-clean-up-and-unrar-scripts-v1-0/17905>\
**Category:** Buttons/Scripts\
**Tags:** script, commands, jscript\
**Created:** [March 24, 2014, 11:29pm UTC](https://resource.dopus.com/t/folder-clean-up-and-unrar-scripts-v1-0/17905 "2014-03-24T23:29:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [March 24, 2014, 11:29pm UTC](https://resource.dopus.com/t/folder-clean-up-and-unrar-scripts-v1-0/17905/1 "2014-03-24T23:29:05Z")

</div>

These scripts are tested but not guaranteed, they are still being tweaked.

If you would like to try them please test against temp folders first. Feedback is welcomed.

### Description

These scrips perform some clean up tasks. Some of these have been written before by others as buttons. Using the new script support should mean that caching of selected files should mean less erroneous changes.

### Functionality

![](https://resource.dopus.com/uploads/default/original/2X/6/6b6d707748423ba354727700b0b5bb872e8edd57.png)

CleanListFolder  
Makes some assumptions about what to do based on this being a list folder.  
A list folder is a folder that contains other items but is not an item. E.G a Movies folder would be a list folder. A movie folder would be an item folder.

- Runs FilesToFolders on all child files, excluding special files (see CleanListFolder\_FilesToIgnore in config) like thumbs.db.
- Runs CleanItemFolder on each child folder.

CleanItemFolder  
Makes some assumptions about what to do based on this being an item folder.

- Collapses certain files (see CleanItemFolder\_FoldersToCollapse in config) like cd1 cd2.
- Runs unrar on all rar files, removing the original file.

CollapseFolder  
Move contents of folder to parent, optionally removing folder  
`c:\a\b.txt` --\> `c:\b.txt`

FilesToFolders  
Move each file to a folder of the same name excluding extension  
`c:\a.txt` --\> `c:\a\a.txt`

unrar  
Unrar given file, optionally remove files if unrar was successful. Requires unrar.exe

Clean Folders menu:

- [Clean Folders.dcf](https://resource.dopus.com/uploads/default/original/3X/e/2/e20eb64e7561caa471d3499dc9a29c3206e0b7c4.dcf) (1.97 KB)
- [How to use buttons and scripts from this forum](https://resource.dopus.com/t/how-to-use-buttons-and-scripts-from-this-forum/3546)

Clean Folder script add-in:

v1.0 (latest):

- [Clean Folder.js.txt](https://resource.dopus.com/uploads/short-url/h9Pvht8Qaj51DKmGO6ZJsDvcgIZ.txt) (34.8 KB)
- Download and drag the file to the list under **Preferences / Toolbars / Scripts**.

v0.2 (older):

- [Clean Folder.osp](https://resource.dopus.com/uploads/default/original/3X/d/b/db9f889e01ce93add7cec8b938df5b6c517cde49.osp) (3.01 KB)

Button to toggle debug output when the other buttons run (toggles the `$glob:debug` global variable):

- [set debug.dcf](https://resource.dopus.com/uploads/short-url/uR7zBnEHg9sLBPtDqW3hN1Es9Tf.dcf) (546 Bytes)

```nohighlight
@toggle:if $glob:debug

@ifset:$glob:debug
 @set $glob:debug
 Set UTILITY=Off
@ifset:else
 @set $glob:debug=true
 Set UTILITY=OtherLog,On

```

---

<div class="post-metadata">

**Author:** ![MSWallack](https://resource.dopus.com/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@MSWallack](https://resource.dopus.com/u/MSWallack)\
**Post date:** [March 27, 2015, 6:32pm UTC](https://resource.dopus.com/t/folder-clean-up-and-unrar-scripts-v1-0/17905/2 "2015-03-27T18:32:46Z")

</div>

I'm working my way back into the scripting world, hoping to try to extend the limited functionality that several people wrote for me last spring. I realized that while I looked at your script last spring, I never dove deep enough into it to truly understand what it was designed to do or how it would actually function. So, I'm wondering if you've done any further development on this script or if you can help me understand how it works. My goal is to use something like this to clean junk out of my \Music folder as I work on renaming and moving music files.

---

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [April 11, 2015, 6:17am UTC](https://resource.dopus.com/t/folder-clean-up-and-unrar-scripts-v1-0/17905/3 "2015-04-11T06:17:59Z")

</div>

I have updated the script to 1.0. There are many improvements and bug fixes.  
Of note this version displays a progress bar as the Clean up List is running.

@MSWallack have you had a chance to look over the script? That would be the best palace to start. If you have any specific questions or get stuck let me know.
