
Creating a Job that moves some files
Now we will create a sample Job that moves some files from one folder to another.
For this exercise, let's suppose that we have a folder with the following files:
ARTIST_1.MP3
ARTIST_2.MP3
ARTIST_3.MP3
ARTIST_4.MP3
error_2.png
error-jira.png
error-vpn.png
MySongs.mp3
SONG_2.MP3
THEBESTSONG.MP3
Our Job will move the mp3 files with name starting with ARTIST to a new folder named MUSIC. If the folder doesn't exists, the Job will write a message to the log.
Let's work on that:
- Open Spoon, create a new Job, and drag the START entry to the work area.
- Now add the following entries: the Checks if files exist entry from the Conditions category, the Move Files entry from the File Management category, and the Abort entry from the Utility category. Link the entries as follows:

Job for moving files
- Despite the name, the Checks if files exist entry serves for checking the existence of both files and folders. We will use it for verifying the existence of the MUSIC folder. So, double-click the entry and in the first cell of the grid, type the full path for the folder, for example, D:/LearningPDI/MUSIC.
- Double-click the Abort entry. In the Message: textbox, type the following text, replacing the path with your own path: The destination folder [D:/LearningPDI/MUSIC] doesn't exist.
Now let's configure the core entry for this Job, the entry that will move the files:
- Double-click the Move Files entry for configuring the movement of the files.
- To the right of the File/Folder source label, type the full path for the source folder containing the files, for example, D:/LearningPDI/SAMPLEFILES. As an alternative, click on the Folder... button just to the right of the textbox and browse for the folder.
- To the right of the File/Folder destination label, type the full path of the MUSIC folder. As an alternative, if the folder already exists, you could click on the Folder... button beside the label and browse for the folder to avoid typing.
- Besides the label Wildcard (RegExp), you will have to type a regular expression indicating which file or files you want to move. In this case, the expression is ARTIST_.*\.MP3, that is, all the files starting with ARTIST_ and with extension MP3.
- Click on Add. All the content that you just typed will be moved to the following grid. The final configuration will be like this:

Configuring a move files entry
- Close the window and save the Job.
Now let's see how this works:
- Run the Job. As the folder didn't exist, the Job will fail. In the Logging tab, you will see the abort message.
- Now create the MUSIC folder by hand.
- Run the Job again. This time, as Log Level: select Detailed. The Job will succeed, and in the Logging tab, you will see the details of the moved files:
... - Starting job entry
... - Processing row source File/folder source : [D:/SAMPLEFILES] ... destination file/folder : [D:/LearningPDI/MUSIC]... wildcard : [ARTIST_.*(backslash).MP3]
... -
... - Fetching folder [file:///D:/SAMPLEFILES]
... - File [file:///D:/SAMPLEFILES/ARTIST_1.MP3] was moved to file:///D:/LearningPDI/MUSIC/ARTIST_1.MP3
... - File [file:///D:/SAMPLEFILES/ARTIST_2.MP3] was moved to file:///D:/LearningPDI/MUSIC/ARTIST_2.MP3
... - File [file:///D:/SAMPLEFILES/ARTIST_3.MP3] was moved to file:///D:/LearningPDI/MUSIC/ARTIST_3.MP3
... - File [file:///D:/SAMPLEFILES/ARTIST_4.MP3] was moved to file:///D:/LearningPDI/MUSIC/ARTIST_4.MP3
... - =======================================
... - Total files in error : 0
... - Total files successfully processed : 4
... - =======================================
You can verify that the Job effectively moved the files by browsing your file system. You should find the new folder containing the four files:
- ARTIST_1.MP3
- ARTIST_2.MP3
- ARTIST_3.MP3
- ARTIST_4.MP3
Also, you shouldn't see these files in the source folder.
As you can see, moving some files is really a simple task. This also occurs with other operations, as, for example, copying or deleting files. Despite the simplicity, there are a couple of things that are new and deserve our attention.