# Move or Copy Non Audio Files

These statements are used to move or copy non audio files from one or more source folders to other folders. The statements can also be used to rename non audio files as they are moved or copied.

These statements will not process audio files of types handled by Yate, folders or hidden files. Note that audio files of types not handled by Yate will be processed.

All text fields support the escape sequences described in Escape Sequences. Note that the fields are only unescaped once, regardless as to how many files are selected.

You can specify specific files or types of files to be processed in the Move/Copy files... field by separating the items with slash characters (/). This field is an inclusion list. Non leading and trailing spaces are significant. For example:

> folder.jpg/Cover Art.jpg/png

The above example will move files named folder.jpg, cover Art.jpg and any file with a file type (extension) of png.

When the Move/Copy files... field is empty, all non audio types (excluding those mentioned above and those specified as exclusions) will be moved.

Items in the list can be forced to match only file types by starting the item with a period. Items in the list can be forced to match only files by ending the item with a period. Forcing the match type should only be necessary in extreme cases. For example:

> txt./.jpg

The above example will match files named txt and any file with a file type of jpg.

You can also specify a rename pattern for files being processed. This is only valid for fully qualified filenames or folder names. You specify the new name following a : character. For example to rename files named cover.jpg to folder.jpg you would specify the following:

> cover.jpg:folder.jpg

You can specify files and file types that are to be excluded from being moved. Enter the list of exclusions in the Exclude files... field. The field is formatted the same as the Move files... field. Excluding files only makes sense if the extension of the file being excluded was specified in the Move files... field. Excluding file types only makes sense if the Move files... field is empty. For example:

> folder.jpg/cover files.png/pdf

Note that these statements ignore alphabetic case when processing files to be moved.

The source and destination folders are obtained in one of three ways:

Folders from variables
  You specify the track variable containing the source folder and the track variable containing the destination folder. The track variables must contain absolute paths (/), paths relative to the home folder (~/) or paths immediately relative to the containing track's path (., .., ./ or ../). You can use the Get Property - Path to Folder statement to extract the folder containing a track. If a path references an audio file, the folder containing the audio file will be used. If a path cannot be resolved to be absolute, it is ignored.
Using retained paths
  This specifies that a non empty Retained Path 2 should be the source of the process and a non empty Retained Path 1 should be the destination of the process. These properties are set by the Move and Copy Files statements.
Use original and current folders
  Every track has a current folder and an original folder. The original folder is the folder containing a track when it is first loaded.

Destination folders will be created if they do not exist.

You can specify that you want to move contained subfolders by selecting the Attempt to move subfolders option. By default a subfolder can be moved if it does not already exist at the destination and none of its descendents is an audio file. You can override the already exists condition by setting the Overwrite existing subfolders option. Be extremely careful when chosing to overwrite subfolders. Overwriting a subfolder causes the entire original subfolder to be deleted!

When you are attempting to move or copy subfolders, all subfolders will be processed (unless hidden). When processing a subfolder the inclusion list is ignored, however the exclusion list is still processed. This means that when attempting to move subfolders, all subfolders in a source folder will be processed unless they are explicitly named in the exclusion list. Note that the contents of a subfolder are always processed if the subfolder is processed. The inclusion and exclusion lists are ignored for subfolder contents. Note that subfolders cannot be renamed using the : construct unless you have this option selected.

If a subfolder already exists and it is the destination folder, it will be ignored. If the destination folder is a descendent of a subfolder, the subfolder will not be processed. If you are copying and a destination folder is the same as a source folder, an error will be raised.

When Moving, you can specify that you want a source folder to be deleted after a move if it is empty. Check the Delete empty folder option. Additionally if you delete the original folder you can delete an empty parent folder as well by checking the and empty parent option. Note that when the Attempt to move subfolders option is enabled, empty sub folders are moved.

By default existing files are overwritten by this statement! If you set the Preserve existing files option, existing files will be preserved. Files with duplicate names will have a (#) sequence appended.

The exact algorithm for determining which files get moved is as follows:

1. If a file starts with a '.', it is a hidden file and is ignored.
2. If a file has the invisible attribute, it is ignored.
3. If a file is an audio type handled by Yate, it is ignored.
4. If the Move files... list is not empty and a file, (not a subfolder), cannot be matched against an item in the Move files... list, the file is ignored. A match can be a full filename match or a file type (extension) match.
5. If a file is matched against an item in the Exclude files... list, it is ignored. A match can be a full filename match or a file type (extension) match.
6. If a file is a folder, and Attempt to move subfolders is not specified, it is ignored. If the subfolder has any audio files as descendents, it is ignored. If the subfolder is the destination folder, it is ignored.
7. The file is moved or copied.

Note that Copy Non Audio Files ignores files where the source and destination folder are the same. Move Non Audio Files will not do so if there is any renaming that has been specified. This is to enable the renaming of non audio files. To rename one or more audio files do the following:

- Set a track variable to the folder containing the file(s) to be renamed.
- Create a Move Non Audio File statement
  - Configure folders from variables.
  - Specify the same track variable as was configured above for both the source and destination.
  - Specify one or more old name:new name items separated by / characters in the first text field. If you want to construct the list at runtime, place the constructed list in a named variable and specify the named variable in the first text field.
  - No not enable Attempt to move subfolders.

Rename examples. Track variable 0 contains the folder path:

    Move non audio files 'oldname.jpg:newname.jpg' from Variable 0 to Variable 0

    Set named variable 'rename list' to "oldname1.jpg:newname1.jpg/oldname2.jpg:newname2.jpg"
    Move non audio files '\<rename list>' from Variable 0 to Variable 0

At times, you may have to decide at runtime if you want to move or copy non audio files. The Move Non Audio Files statement has an Allow runtime override setting. If you enable the setting and named variable Override Move to Copy is true (non zero integer or "true"), the Move Non Audio Files statement will effectively become a Copy Non Audio Files statement. When overridden the folder deletion settings will be ignored. Note that the Move statement can also overide its functionality at runtime and uses the same named variable.