![]() |
|
|
#1 |
![]() Join Date: Oct 2009
Location: Starkville, MS
Posts: 878 (0.67/day)
Thanks: 1,002
Thanked 256 Times in 190 Posts
|
scripting help
Hi guys,
I'm not familiar with scripting but I have a task and have found no program to accomplish the task. I read alot of ebooks in different formats: epub, pdf, rtf, etc I have different folders for the formats. I have to move them from the Downloads folder to the respective folders which can be annoying and time consuming since there tend to be quite a few. I need either a script or a program that can watch my Downloads folder and move the files to the folders. The path for the downloads folder is /home/ian/Downloads The path for the RTF folder is: /home/ian/Documents/Fanfiction/RTF The path for the EPUB folder is: /home/ian/Documents/Fanficiton/EPUB The path for the PDF folder is: /home/ian/Documents/Fanfiction/PDF and the path for the HTML folder is: /home/ian/Documents/Fanfiction/HTML There is a windows program that does this called QuickMove. |
|
|
|
|
|
#2 |
|
Moderato®™
Join Date: Apr 2009
Location: Statesville, NC
Posts: 3,623 (2.42/day)
Thanks: 4,313
Thanked 2,316 Times in 1,148 Posts
|
Here is a batch file you can use.
Copy this into a text file and rename the text file to .bat Code:
@echo off color 9F echo ### Mindweaver's File Mover ECHO --------------------------- ECHO - ECHO - ECHO Select a type of file to move. ECHO 1. PDF ECHO 2. RTF ECHO 3. EPUB ECHO 4. HTML ECHO 5. ALL set PDF=%USERPROFILE%\Downloads\*.pdf set RTF=%USERPROFILE%\Downloads\*.rtf set EPUB=%USERPROFILE%\Downloads\*.epub set HTML=%USERPROFILE%\Downloads\*.html set folder1=%USERPROFILE%\Documents\PDF set folder2=%USERPROFILE%\Documents\RTF set folder3=%USERPROFILE%\Documents\EPUB set folder4=%USERPROFILE%\Documents\HTML set Movecmd=Move /y set /p userinp=choose a number(1-5): set userinp=%userinp:~0,1% if "%userinp%"=="1" goto 1 if "%userinp%"=="2" goto 2 if "%userinp%"=="3" goto 3 if "%userinp%"=="4" goto 4 if "%userinp%"=="5" goto 5 :1 CLS echo ### Moving PDF's %Movecmd% "%PDF%" "%folder1%" GOTO EXIT :2 CLS echo ### Moving RTF's %Movecmd% "%RTF%" "%folder2%" GOTO EXIT :3 CLS echo ### Moving EPUB's %Movecmd% "%EPUB%" "%folder3%" GOTO EXIT :4 CLS echo ### Moving HTML's %Movecmd% "%HTML%" "%folder4%" GOTO EXIT :5 CLS echo ### Moving PDF's %Movecmd% "%PDF%" "%folder4%" echo 25% complete %Movecmd% "%RTF%" "%folder2%" echo 50% complete %Movecmd% "%EPUB%" "%folder3%" echo 75% complete %Movecmd% "%HTML%" "%folder4%" GOTO EXIT :EXIT echo Move Complete! @pause
__________________
“As long as I feel the warmth from the sun and breathe precious air…. I must ask questions to feed the Mind!” Battletag: Mindweaver#1523 |
|
|
|
| The Following User Says Thank You to Mindweaver For This Useful Post: |
|
|
#3 |
![]() Join Date: Oct 2009
Location: Starkville, MS
Posts: 878 (0.67/day)
Thanks: 1,002
Thanked 256 Times in 190 Posts
|
This will work in linux right? It looks very close to BASIC
|
|
|
|
|
|
#4 | |
|
Moderato®™
Join Date: Apr 2009
Location: Statesville, NC
Posts: 3,623 (2.42/day)
Thanks: 4,313
Thanked 2,316 Times in 1,148 Posts
|
Quote:
Sorry buddy and I moved this thread back to the Linux thread.EDIT: I left the code here for Windows users.. Linux would be something like this for the move command. Code:
#!/bin/bash mv from to You can use CASE instead of GOTO
__________________
“As long as I feel the warmth from the sun and breathe precious air…. I must ask questions to feed the Mind!” Battletag: Mindweaver#1523 Last edited by Mindweaver; Dec 26, 2012 at 02:47 PM. |
|
|
|
|
| The Following 2 Users Say Thank You to Mindweaver For This Useful Post: |
|
|
#5 | |
![]() Join Date: Jan 2012
Location: Dover, New Hampshire, USA
Posts: 4,237 (8.87/day)
Thanks: 1,262
Thanked 1,315 Times in 977 Posts
|
Quote:
It would look something like this (I don't think a UI is necessary): Code:
#!/bin/bash pathfrom="/path/to/downloads/folder" pathto="/path/to/store/files" mv "$pathfrom/*.pdf" "$pathto/PDF" mv "$pathfrom/*.rtf" "$pathto/RTF" mv "$pathfrom/*.epub" "$pathto/EPUB" mv "$pathfrom/*.html" "$pathto/HTML" Edit: If you wanted a UI, you could easily just add a SWITCH/CASE statement plus a little usage output. @Mindweaver: Ewww, really? GOTO?
__________________
MyHeat |
|
|
|
|
| The Following 2 Users Say Thank You to Aquinus For This Useful Post: |
|
|
#6 |
![]() Join Date: Aug 2009
Location: Montana
Posts: 2,018 (1.45/day)
Thanks: 2,535
Thanked 1,323 Times in 917 Posts
|
Just use Calibre and convert them into one file type, or keep them all in a single Calibre folder since Calibre will open them all, anyhow.
|
|
|
|
|
|
#7 | |
![]() Join Date: Oct 2009
Location: Starkville, MS
Posts: 878 (0.67/day)
Thanks: 1,002
Thanked 256 Times in 190 Posts
|
Quote:
****Update**** Here is what I get when I run the script. Code:
ian@ian-Lenovo-G570:~$ ./quickmove.sh ./quickmove.sh: line 2: pathfrom: command not found ./quickmove.sh: line 3: pathto: command not found mv: cannot stat `/*.pdf': No such file or directory mv: cannot stat `/*.rtf': No such file or directory mv: cannot stat `/*.epub': No such file or directory mv: cannot stat `/*.html': No such file or directory ian@ian-Lenovo-G570:~$ ./quickmove.sh ./quickmove.sh: line 2: /home/ian/Downloads: Is a directory ./quickmove.sh: line 3: /home/ian/Documents/Fanfiction: Is a directory mv: cannot stat `/*.pdf': No such file or directory mv: cannot stat `/*.rtf': No such file or directory mv: cannot stat `/*.epub': No such file or directory mv: cannot stat `/*.html': No such file or directory ian@ian-Lenovo-G570:~$ Code:
#!/bin/bash pathfrom= "/home/ian/Downloads" pathto= "/home/ian/Documents/Fanfiction" mv "$pathfrom/*.pdf" "$pathto/PDF" mv "$pathfrom/*.rtf" "$pathto/RTF" mv "$pathfrom/*.epub" "$pathto/EPUB" mv "$pathfrom/*.html" "$pathto/HTML" Last edited by Killer_Rubber_Ducky; Dec 26, 2012 at 10:45 PM. |
|
|
|
|
|
|
#8 | |
|
Moderato®™
Join Date: Apr 2009
Location: Statesville, NC
Posts: 3,623 (2.42/day)
Thanks: 4,313
Thanked 2,316 Times in 1,148 Posts
|
Quote:
![]() Code:
#!/bin/bash mv /home/ian/Downloads /home/ian/Documents/Fanfiction/PDF mv /home/ian/Downloads /home/ian/Documents/Fanfiction/RTF mv /home/ian/Downloads /home/ian/Documents/Fanfiction/EPUB mv /home/ian/Downloads /home/ian/Documents/Fanfiction/HTML
__________________
“As long as I feel the warmth from the sun and breathe precious air…. I must ask questions to feed the Mind!” Battletag: Mindweaver#1523 |
|
|
|
|
| The Following User Says Thank You to Mindweaver For This Useful Post: |
|
|
#9 | ||
![]() Join Date: Oct 2009
Location: Starkville, MS
Posts: 878 (0.67/day)
Thanks: 1,002
Thanked 256 Times in 190 Posts
|
Quote:
Quote:
Here is my code: Code:
#!/bin/bash #Ian's File Moving Script shopt -s extglob mv -f $HOME/Downloads/*.pdf $HOME/Documents/Fanfiction/PDF mv -f $HOME/Downloads/*.rtf $HOME/Documents/Fanfiction/RTF mv -f $HOME/Downloads/*.epub $HOME/Documents/Fanfiction/EPUB mv -f $HOME/Downloads/*.html $HOME/Documents/Fanfiction/HTML/NewDownloads/December |
||
|
|
|
|
|
#10 | |||
![]() Join Date: Jan 2012
Location: Dover, New Hampshire, USA
Posts: 4,237 (8.87/day)
Thanks: 1,262
Thanked 1,315 Times in 977 Posts
|
Quote:
Quote:
Quote:
Code:
#correct: variablex="applepie" #incorrect: variablex= "applepie"
__________________
MyHeat |
|||
|
|
|
| The Following 2 Users Say Thank You to Aquinus For This Useful Post: |
|
|
#11 | |
![]() Join Date: Mar 2012
Location: Bandung, Indonesia
Posts: 363 (0.87/day)
Thanks: 103
Thanked 73 Times in 45 Posts
|
Quote:
Code:
#!/bin/bash $pathfrom="/path/to/downloads/folder" $pathto="/path/to/store/files" mv "$pathfrom/*.pdf" "$pathto/PDF" mv "$pathfrom/*.rtf" "$pathto/RTF" mv "$pathfrom/*.epub" "$pathto/EPUB" mv "$pathfrom/*.html" "$pathto/HTML" Code:
#correct: $variablex="applepie" #correct: $variablex= "applepie"
__________________
![]() And if you hear me talking on the wind You've got to understand We must remain perfect strangers [Deep Purple - Perfect Strangers] |
|
|
|
|
|
|
#12 |
![]() Join Date: Jan 2012
Location: Dover, New Hampshire, USA
Posts: 4,237 (8.87/day)
Thanks: 1,262
Thanked 1,315 Times in 977 Posts
|
Someone doesn't know what they're talking about and should refrain from posting when that is the case.
![]() Sounds like the OP poster isn't the only person who needs to learn BASH... Code:
jdoane@khan:~$ somevar1="someweirdstring" jdoane@khan:~$ somevar2= "someweirdstring" someweirdstring: command not found jdoane@khan:~$ echo $somevar1 someweirdstring jdoane@khan:~$ echo $somevar2 jdoane@khan:~$ Code:
jdoane@khan:~$ $someothervar="applepie" =applepie: command not found
__________________
MyHeat Last edited by Aquinus; Dec 27, 2012 at 12:57 AM. |
|
|
|
|
|
#13 | |
![]() Join Date: Oct 2009
Location: Starkville, MS
Posts: 878 (0.67/day)
Thanks: 1,002
Thanked 256 Times in 190 Posts
|
Quote:
|
|
|
|
|
| The Following User Says Thank You to Killer_Rubber_Ducky For This Useful Post: |
|
|
#14 | |
![]() Join Date: Jan 2012
Location: Dover, New Hampshire, USA
Posts: 4,237 (8.87/day)
Thanks: 1,262
Thanked 1,315 Times in 977 Posts
|
Quote:
![]() Nice! Back when I was in school I wrote a networked version of Backgammon using Java in my second year while I was working on my Computer Science degree. It's fun stuff, at least to me.
__________________
MyHeat |
|
|
|
|
|
|
#15 | |
![]() Join Date: Mar 2012
Location: Bandung, Indonesia
Posts: 363 (0.87/day)
Thanks: 103
Thanked 73 Times in 45 Posts
|
Quote:
![]() i found it funny.. thanks for your correction
__________________
![]() And if you hear me talking on the wind You've got to understand We must remain perfect strangers [Deep Purple - Perfect Strangers] |
|
|
|
|
| The Following User Says Thank You to SIGSEGV For This Useful Post: |
|
|
#16 | |
![]() Join Date: Jan 2012
Location: Dover, New Hampshire, USA
Posts: 4,237 (8.87/day)
Thanks: 1,262
Thanked 1,315 Times in 977 Posts
|
Quote:
__________________
MyHeat |
|
|
|
|
|
|
#17 | |
|
Moderato®™
Join Date: Apr 2009
Location: Statesville, NC
Posts: 3,623 (2.42/day)
Thanks: 4,313
Thanked 2,316 Times in 1,148 Posts
|
Quote:
I'd rather him start out not using variables until he understands bash better. Call it bias of me, but I tend not to give the full answer as quickly to Linux users as I do Windows users. I know I shouldn't, but I do..
__________________
“As long as I feel the warmth from the sun and breathe precious air…. I must ask questions to feed the Mind!” Battletag: Mindweaver#1523 |
|
|
|
|
| The Following User Says Thank You to Mindweaver For This Useful Post: |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Scripting using Autoit | brandonwh64 | Programming & Webmastering | 0 | Jan 6, 2011 04:07 PM |
| Bash scripting help | nick_1992 | Programming & Webmastering | 2 | Dec 12, 2010 05:50 AM |
| PIE scripting Help | sonnytiger | Games | 0 | Feb 12, 2010 02:38 PM |
| cross-site scripting | a111087 | Comments & Feedback | 15 | Dec 21, 2008 05:57 PM |