Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Advanced Symlink Creation script Post 302675265 by Davinator on Sunday 22nd of July 2012 02:04:01 PM
Old 07-22-2012
Advanced Hardlink Creation script

Hello. I am working on creating a script to recursively run on my media collection. The goal is to recreate the folder structure, but with slight changes in the folder names based on my rules. The folders will also include the .jpg & .mkv files, renamed according to a similar set of rules.

Normally I would ask a portion of the script and piece the entire script together with my limited knowledge, however in this case I don't think that will come up with a very streamlined script at all. So, I'm going to explain my goal, and hope someone is willing to help me out!!

Here is my current directory structure:
Code:
/cygwindrive/c/Media/{Genre}/+Example Title 1/Folder.jpg
/cygwindrive/c/Media/{Genre}/+Example Title 1/Example Title 1 - 2001/Example Title 1 - 2001 - ExtraTextNoSpaces12345.mkv
/cygwindrive/c/Media/{Genre}/+Example Title 1/Example Title 1 - 2001/Example Title 1 - 2001 - ExtraTextNoSpaces12345.mkv_sheet.jpg
/cygwindrive/c/Media/{Genre}/+Example Title 1/Example Title 1 - 2001/Folder.jpg
/cygwindrive/c/Media/{Genre}/Example Title 2 - 2000/Example Title 2 - 2000 - ExtraTextNoSpaces12345.mkv
/cygwindrive/c/Media/{Genre}/Example Title 2 - 2000/Example Title 2 - 2000 - ExtraTextNoSpaces12345.mkv_sheet.jpg
/cygwindrive/c/Media/{Genre}/Example Title 2 - 2000/folder.jpg

Here is my desired directory structure using hardlinks to reference the .mkv & .jpg files:
Code:
/cygwindrive/c/Mediahardlinks/{Genre}/+Example Title 1/Folder.jpg
/cygwindrive/c/Mediahardlinks/{Genre}/+Example Title 1/Example Title 1 - 2001/Example Title 1 - 2001.mkv
/cygwindrive/c/Mediahardlinks/{Genre}/+Example Title 1/Example Title 1 - 2001/Example Title 1 - 2001.mkv_sheet.jpg
/cygwindrive/c/Mediahardlinks/{Genre}/+Example Title 1/Example Title 1 - 2001/Folder.jpg
/cygwindrive/c/Mediahardlinks/{Genre}/Example Title 2 - 2000/Example Title 2 - 2000.mkv
/cygwindrive/c/Mediahardlinks/{Genre}/Example Title 2 - 2000/Example Title 2 - 2000.mkv_sheet.jpg
/cygwindrive/c/Mediahardlinks/{Genre}/Example Title 2 - 2000/folder.jpg

So the goal is fairly straightforward - I want to recreate the directory structure of /cygwindrive/c/Media/ into /cygwindrive/c/Mediahardlinks/. Then I want to create hardlinks for all the .jpg & .mkv files in those directories, however I want to remove the " - ExtraTextNoSpaces12345" string within the .mkv & .mkv_sheet.jpg files in the hardlinks names. It should be noted that this text always appears after the 4 digit Year text in the filenames, will never have spaces, and is always the exact same within any given folder (since the .jpg file references the .mkv file). Also, the directory structure of /cygwindrive/c/Media/ includes other files in addition to the .jpg & .mkv files, however I am only interested in making the hardlinks to those types of files.

I would be extremely grateful is anyone would be willing to take the time to help me out with this script. Thanks in advance for the help!

Last edited by Davinator; 07-22-2012 at 03:37 PM.. Reason: Changed symlink to hardlink
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

creating symlink

hi... I have a folder<abc> under /root folder. I want to create a symlink such that when i click on folder<abc> under root, should display my home folder (home/krish). Immediate inputs appreciated..... (1 Reply)
Discussion started by: rama.honge
1 Replies

2. Shell Programming and Scripting

Need help in a shell script to edit a tablespace creation script.

Hi, CREATE TABLESPACE aps_blob_large01 DATAFILE '/c2r6u13/u03/oradata/qnoldv01/aps_blob_large0101.dbf' SIZE X 270532608 REUSE DEFAULT STORAGE (INITIAL 134217728 NEXT... (2 Replies)
Discussion started by: rparavastu
2 Replies

3. Solaris

symlink on link file

Hi all, I want to create a symlink on a link file, i mean, there is a file which is actually a symlink of some version. Now i want to create one more symlink on that link file. EX: there is a file: uat -> version prod -> version Now i want to create one more link on these 'uat' and... (1 Reply)
Discussion started by: raghu.iv85
1 Replies

4. UNIX for Dummies Questions & Answers

[solved] Script creation (how to include options in the script)

Hi guys i have written a script which takes the options given to him and execute itself accordingly. for example if a script name is doctortux then executing doctortux without option should made doctortux to be executed in automatic mode i.e. doctortux -a or if a doctortux is needed to run in... (4 Replies)
Discussion started by: pinga123
4 Replies

5. Shell Programming and Scripting

Need an advanced version of this script

Hi there, i am completely new to this great forum and to linux. Since 3 days i work with Ubuntu Lucid Lynx and i love the powers of the shell. This script helped me a lot to understand the process a little bit. Now my problem. I have this data set, tab delimited: ... (4 Replies)
Discussion started by: shasha7
4 Replies

6. Shell Programming and Scripting

User creation script

Hi Gems.. I am working out on project of creating a mass user on 100 server. Please help me with script where i can create an user id of new 80 user using shell script Thanks in advance. Indrajit Bhagat (1 Reply)
Discussion started by: indrajit_renu
1 Replies

7. Shell Programming and Scripting

ln -s creates symlink in symlink, if [ -f ... ] says file that exists doesn't exist

Hi Forums, I got a little problem, I made a few modifications to the code of the launch script of a testing server(minecraft) and now updating is broken aswell as the automatic directory creation. These Lines somehow create an endless symlink that refers to itself and I don't know how to fix... (0 Replies)
Discussion started by: Xaymar
0 Replies

8. Shell Programming and Scripting

Help with Playlist creation script

Hello. I am hoping to have an automated way to create Playlist files from Genre txt files I'll be making with my music collection. This is for use with my WD Live player, and is so that certain albums / artists can live in multiple genre directories when I browse to them from my WD Live player. ... (4 Replies)
Discussion started by: Davinator
4 Replies

9. Shell Programming and Scripting

Symlink creation

I am trying to setup my plex server to use symlinks rather than host the movie files. in my storage directory, i have both movies(some in subdirectory of the name and some just in the parent directory) and tvshows, which have subdirectories for each season, which contains the episodes i would... (3 Replies)
Discussion started by: bandion
3 Replies

10. UNIX for Beginners Questions & Answers

Symlink

I know how to create a symlink but I am getting an error message that the file already exists. Also, my symlink doesn't point from target directory to the path correctly, Here is an example of the path to my folder structure path: cd /wkspce/wff/DEV/jobs/DEL the folder structure is: ... (3 Replies)
Discussion started by: dellanicholson
3 Replies
refile(1mh)															       refile(1mh)

Name
       refile - file message in other folders

Syntax
       refile [ msgs ] [ +folder ] [ options ]

Description
       Use  the  command to move the specified message from the current folder to another folder.  You can refile messages in more than one folder
       by giving multiple folder names as arguments.

       If you do not specify a message, the current message is refiled.  You can refile a message other than the current  message  by  giving  its
       number  as  a msgs argument.  You can also refile more than one message at a time by specifying more than one message number, or a range of
       message numbers, or a message sequence.	See for more information on sequences.

       The current folder remains the same unless the -src option is specified; in that case, the source folder becomes  current.   Normally,  the
       last message specified becomes the current message.  However, if the -link option is used, the current message is not changed.

       If  the	Previous-Sequence:  entry is set in the file, in addition to defining the named sequences from the source folder, will also define
       those sequences for the destination folders.  See for information concerning the previous sequence.

Options
       -draft	 Refiles the draft message, or the current message in your folder, if you have one set up.  You cannot give a msgs  argument  when
		 you use this option.

       -file filename
		 Moves	a  file into a folder.	This option takes a file from its directory and places it in the named folder, as the next message
		 in the folder.  The file must be formatted as a legal mail message.  This means that the message must	have  the  minimum  header
		 fields separated from the body of the message by a blank line or a line of dashes.

       -help	 Prints a list of the valid options to this command.

       -link
       -nolink	 Keeps	a copy of the message in the source folder.  Normally, removes the messages from the original folder when it refiles them.
		 The -link option keeps a copy in the original folder, as well as filing a copy in the new folder.

       -preserve
       -nopreserve
		 Preserves the number of a message in the new folder.  Normally, when a message is refiled in to another folder, it is set to  the
		 next  available number in that folder.  The -preserve option keeps the number of the message the same in the new folder as it had
		 been in the old.

		 You cannot have two messages with the same number in one folder, so you should use this option with care.

       -src +folder
		 Specifies the source folder to take messages from.  Normally, messages are refiled from the current folder into  another  folder.
		 However, you can take messages from a different folder by using the -src +folder option to specify the alternative source folder.

Examples
       The following example refiles messages 3 and 5 in the folder
       % refile 3 5 +records

       The next example files the current message into two folders:
       % refile +jones +map

       The next example takes message 13 in the current folder and refiles it in the folder.  The message remains in the current folder as well as
       appearing in the folder.
       % refile -link 13 +test

       The next example takes a message from the folder when it is not the current folder, and places it in the folder
       % refile 3 -src +test +outbox

Profile Components
       Path:		 To determine your Mail directory

       Folder-Protect:	 To set protections when creating a new folder
       rmmproc: 	 Program to delete the message

Files
       The user profile.

See Also
       folder(1mh), mark(1mh), mh_profile(5mh)

																       refile(1mh)
All times are GMT -4. The time now is 01:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy