Advanced Symlink Creation script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Advanced Symlink Creation script
# 1  
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
# 2  
Old 07-22-2012
You seem to be in Cygwin. Do symlinks even work there? That's not the same thing as a .lnk, you know.
# 3  
Old 07-22-2012
Quote:
Originally Posted by Corona688
You seem to be in Cygwin. Do symlinks even work there? That's not the same thing as a .lnk, you know.
Yeah, I've already confirmed they work in my setup. I tested using a simple ln command with no flags, and it works perfectly. I think the reason it works is because my end-device is linux-based.

Here's an example ln command I used when testing:

Code:
ln "/cygwindrive/c/Media/{Genre}/+Example Title 1/Example Title 1 - 2001/Example Title 1 - 2001 - ExtraTextNoSpaces12345.mkv" "/cygwindrive/c/MediaHardlinks/{Genre}/+Example Title 1/Example Title 1 - 2001/Example Title 1 - 2001.mkv"


Last edited by Davinator; 07-22-2012 at 03:35 PM.. Reason: Added ln example
# 4  
Old 07-22-2012
That isn't a symlink either, that's a hardlink. ln -s creates symlinks.
# 5  
Old 07-22-2012
Quote:
Originally Posted by Corona688
That isn't a symlink either, that's a hardlink. ln -s creates symlinks.
Yeah, you are absolutely correct, my mistake. I've updated my posts accordingly changing symlinks to hardlinks.

I guess this is why I'm posting in the newbies area Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question