Simply Smart Renamer.

troikas | Δευ, 09/06/2010 - 17:22 | 5' | 21

S.S.re (simply smart renamer)

 Έχει συμβεί σε πολλούς να θέλουν να μετονομασθούν, μερικά αρχεία σε έναν φάκελο που περιέχει πάρα πολλά αρχεία π.χ σε έναν φάκελο με 50 αρχεία θέλω να μετονομασθούν το πρώτο το δέκατο και το εικοστoπεμτο, τότε θα ανοίξω το φάκελο με τα αρχεία θα ψάξω και θα μετονομασω με δεξί κλικ αυτά που θέλω.
Έμενα μου φάνηκε λίγο βαρετή η όλη διαδικασία και γι' αυτό έφτιαξα το S.S.Re (simply smart renamer). Τη κάνει το S.S.Re? Λοιπόν παίρνει όλα τα ονόματα από τα αρχεία που βρίσκονται στο φάκελο που το τρέχετε και σας τα βγάζει σε ένα editable info box, εκεί κάνετε της αλλαγές που θέλετε το κλείνεται απαντάτε ναι στην ερώτηση που θα βγει και όλα τα αρχεία έχουν μετονομαστεί.

ΠΡΟΣΟΧΗ ΣΤΗΝ ΜΕΤΟΝΟΜΑΣΙΑ ΑΛΛΑΖΕΤΑΙ ΤΟ ΟΝΟΜΑ ΜΟΝΟ ΔΕΝ ΑΛΛΑΖΟΥΜΕ ΤΗΝ ΚΑΤΑΛΗΞΗ. ΔΗΛΑΔΗ ΑΛΛΑΓΕΣ ΠΡΙΝ ΤΗΝ ΤΕΛΕΙΑ. Μόνο σε μια περίπτωση κάνουμε αλλαγές μετά την τελεία (κατάληξη) π.χ έχουμε ένα αρχείο με το όνομα file.JPG και θέλουμε να το κάνουμε file.jpg δηλαδή να κάνουμε τα κεφαλαία μικρά. ΜΟΝΟ ΤΟΤΕ ΑΛΛΑΖΟΥΜΕ ΤΗΝ ΚΑΤΑΛΗΞΗ.

Θα πρέπει να έχετε το zenity στο σύστημα σας και φυσικά να το βάλετε στο δεξί κλικ του Ναυτίλου.

 

  1. #!/bin/bash
  2.  
  3. # S.S.Re (simply smart renamer) a simple tool to rename multiple files.
  4. # This tool is a graphical fronted which uses Zenity and basic command
  5. # line tools to rename multiple files.
  6. # You must have zenity in your system.
  7. # Author: TROiKAS [email protected]
  8.  
  9. # To begin with, set the app title and version
  10. TITLE="S.S.Re"
  11. VERSION="1.0"
  12.  
  13. # Set window title and window width
  14. WINDOW_TITLE=$TITLE" (v"$VERSION")"
  15. WINDOW_WIDTH=325
  16. WINDOW_HEIGHT=500
  17.  
  18. # Paths to needed executables. Please adjust as necessary
  19. Zenity=/usr/bin/zenity
  20. Printf=/usr/bin/printf
  21. Ls=/bin/ls
  22. Sed=/bin/sed
  23. Mv=/bin/mv
  24. Rm=/bin/rm
  25. Notify=/usr/bin/notify-send
  26.  
  27. # Check if Zenity can be found. If not, produce error message
  28. # (with "xmessage", since zenity is not available) and bail out
  29. if [ ! -e "$Zenity" ]; then
  30. xmessage "ERROR: $Zenity not found. You must install the Zenity\
  31. package, or provide an alternative location"
  32. exit
  33. fi
  34.  
  35. # Remove 'space', so filenames with spaces work well.
  36. IFS="`$Printf '\n\t'`"
  37.  
  38. # Take all filenames and write in name.txt
  39. $Ls -1 > .name.txt
  40. FILE=.name.txt
  41.  
  42. # Create text info dialog with filenames.
  43. # Here you can edit the filenames.
  44. # And save as name.txt.edit
  45. $Zenity --text-info --editable \
  46. --width $WINDOW_WIDTH --height $WINDOW_HEIGHT \
  47. --title="$WINDOW_TITLE" \
  48. --filename=$FILE > $FILE.edit
  49.  
  50. # Create a question dialog if you want rename the files.
  51. $Zenity --question --width $WINDOW_WIDTH --title="$WINDOW_TITLE" \
  52. --text="Do you want to rename the files?"
  53.  
  54. # Start rename the files.
  55. if [[ $? == 0 ]] ; then
  56. a=1
  57. for i in `$Ls`
  58. do
  59. Line=$($Sed -ne "$a p" $FILE.edit)
  60. echo $Line
  61. $Mv -n $i $Line
  62. a=$[$a + 1]
  63.  
  64. done
  65. else
  66.  
  67. # If user abort stop everything remove all files
  68. # created by the script and then exit.
  69. $Rm -rf .name.txt $FILE.edit
  70. exit
  71. fi
  72.  
  73. # Remove all files created by the script
  74. $Rm -rf .name.txt $FILE.edit
  75.  
  76. # Notify when all finish and then exit.
  77. $Notify "$WINDOW_TITLE" \
  78. "All files renamed."
  79.  
  80. exit

Θα ηθελα την γνωμη σας, και μερικες συμβουλες απο οσους γνωριζουν καλυτερα απο σκριπτακια.

 

Φόρουμ
Δώσε αστέρια!

MO: (ψήφοι: 0)

Σχόλια

// *** μη εποικοδομητικό σχόλιο ***

Μπράβο ρε troikas.

απλό, οργανωμένο, όμορφο και σχολιασμέμνο.

 

Καλή αρχή και σύντομα μ'ενα gui

:)

 

PS δεν το δοκίμασα ακόμα

luckyb]

// *** μη εποικοδομητικό σχόλιο ***

Μπράβο ρε troikas.

απλό, οργανωμένο, όμορφο και σχολιασμέμνο.

 

Καλή αρχή και σύντομα μ'ενα gui

:)

 

PS δεν το δοκίμασα ακόμα

Ευχαριστω αν το δοκιμασεις πες μου αν κανει σωστα την δουλεια του. Τωρα για gui στην αρχη ειμαι ακομη μαθαινω.

Body Mind Spirit

// ***δεύτερο μη επικοδομητικό σχολιο ***

Πολύ χρήσιμο μου φαίνεται... Δυο παρατηρήσεις: Τι άδεια χρήσης έχει; Καλό θα ήταν να το προσθέσεις. Επίσης, θα ήταν καλύτερο όλη δουλειά να γίνεται στο /tmp και όχι στο /home? 

Teddy]

// ***δεύτερο μη επικοδομητικό σχολιο ***

Πολύ χρήσιμο μου φαίνεται... Δυο παρατηρήσεις: Τι άδεια χρήσης έχει; Καλό θα ήταν να το προσθέσεις. Επίσης, θα ήταν καλύτερο όλη δουλειά να γίνεται στο /tmp και όχι στο /home? 

Αυτο με την αδεια χρησης μπορει να μου το εξηγησει καποιος? Τι πρεπει να κανω δηλαδη?

Δουλευει στον φακελο που το τρεχεις, αλλα εαν ειναι καλυτερα στο /tmp τοτε θα κανω την αλλαγη.

Body Mind Spirit

Οκ τωρα η δουλεια γινεται στο /tmp .

 

#!/bin/bash
 
# S.S.Re (simply smart renamer) a simple tool to rename multiple files.
# This tool is a graphical fronted which uses Zenity and basic command
# line tools to rename multiple files.
# You must have zenity in your system.
# Author: TROiKAS [email protected]
 
# To begin with, set the app title and version
TITLE="S.S.Re"
VERSION="1.0"
 
# Set window title and window width
WINDOW_TITLE=$TITLE" (v"$VERSION")"
WINDOW_WIDTH=325
WINDOW_HEIGHT=500
 
# Paths to needed executables. Please adjust as necessary
Zenity=/usr/bin/zenity
Printf=/usr/bin/printf
Ls=/bin/ls
Sed=/bin/sed
Mv=/bin/mv
Rm=/bin/rm
Notify=/usr/bin/notify-send
 
# Check if Zenity can be found. If not, produce error message
# (with "xmessage", since zenity is not available) and bail out
if [ ! -e "$Zenity" ]; then
xmessage "ERROR: $Zenity not found. You must install the Zenity  

\

package, or provide an alternative location"
exit fi   # Remove 'space', so filenames with spaces work well. IFS="`$Printf '\n\t'`"   # Take all filenames and write in name.txt $Ls -1 > /tmp/name.txt FILE=/tmp/name.txt   # Create text info dialog with filenames. # Here you can edit the filenames. # And save as name.txt.edit $Zenity --text-info --editable \ --width $WINDOW_WIDTH --height $WINDOW_HEIGHT \ --title="$WINDOW_TITLE" \ --filename=$FILE > $FILE.edit   # Create a question dialog if you want rename the files. $Zenity --question --width $WINDOW_WIDTH --title="$WINDOW_TITLE" \ --text="Do you want to rename the files?"   # Start rename the files. if [[ $? == 0 ]] ; then a=1 for i in `$Ls` do Line=$($Sed -ne "$a p" $FILE.edit) echo $Line $Mv -n $i $Line a=$[$a + 1]   done else   # If user abort stop everything remove all files # created by the script and then exit. $Rm -rf $FILE $FILE.edit exit fi   # Remove all files created by the script $Rm -rf $FILE $FILE.edit   # Notify when all finish and then exit. $Notify "$WINDOW_TITLE" \ "All files renamed."   exit

Περιμενω να μου πει καποιος σχετικα με της αδειες χρησης, για να το διωρθοσω και αυτο.

 

Body Mind Spirit

Εδω Δημητρη το Creative Commons σου κανει γι' αρχη: http://creativecommons.org/licenses/by-nc-nd/3.0/gr/ Πιο πολλα για το θεμα θα σου πει ο Λουκας υποθετω (Luckyb). Ε καλα και στο /home που τρεχει αυτο δεν εχει σημασια πιστευω.....

Το δοκίμασα, δουλεύει όπως θα έπρεπε. 

Το δοκίμασα και για αρχείο που δεν είχα δικαιώματα, που απλά δεν έγινε τίποτα.
 

Δεν ξέρω αν είναι καλύτερα να δουλέψει στο /tmp

 

Και μαλον καλυτερα ειναι να παραμεινει ετσι και να μην ανοιγει αρχεια υπερχρηστη.

Αλλωστε αν μπει στο φακελο με δικαιωμα διαχειριστη καποιος (Οpen As Root), μπορει να το δουλεψει.

 

Nαι, εννοείται οτι πρέπει να μείνει έτσι, για καλό το είπα, δεν κόλλησε, δεν μπερδεύτηκε πουθενά, απλα δεν έκανε τίποτα. 

Τώρα όμως που το έτρεξα απο το /tmp για να μετονομάσω αρχεία εκεί κάπου μπλέχτηκε με το αρχείο που δημιουργείται, οπότε μάλλον κάντο κρυφό. Κάτι σαν αυτό

$Ls -1 > /tmp/.name.txt
 FILE=/tmp/.name.txt 

κάνει;
 

(Είναι πιθανό ο χρήστης να δουλέψει στο /tmp πχ για να αποθηκεύσει βιντεάκια απο flash)

Επιστροφη στην αρχικη του μορφη δουλευει σε κρυφα αρχεια .name.txt και .name.txt.edit  στο φακελο που το τρεχετε, τα οποια τα σβηνη οταν τελειοση την δουλεια του.

  1. #!/bin/bash
  2.  
  3. # S.S.Re (simply smart renamer) a simple tool to rename multiple files.
  4. # This tool is a graphical fronted which uses Zenity and basic command
  5. # line tools to rename multiple files.
  6. # You must have zenity in your system.
  7. # Author: TROiKAS [email protected]
  8.  
  9. # To begin with, set the app title and version
  10. TITLE="S.S.Re"
  11. VERSION="1.0"
  12.  
  13. # Set window title and window width
  14. WINDOW_TITLE=$TITLE" (v"$VERSION")"
  15. WINDOW_WIDTH=325
  16. WINDOW_HEIGHT=500
  17.  
  18. # Paths to needed executables. Please adjust as necessary
  19. Zenity=/usr/bin/zenity
  20. Printf=/usr/bin/printf
  21. Ls=/bin/ls
  22. Sed=/bin/sed
  23. Mv=/bin/mv
  24. Rm=/bin/rm
  25. Notify=/usr/bin/notify-send
  26.  
  27. # Check if Zenity can be found. If not, produce error message
  28. # (with "xmessage", since zenity is not available) and bail out
  29. if [ ! -e "$Zenity" ]; then
  30. xmessage "ERROR: $Zenity not found. You must install the Zenity\
  31. package, or provide an alternative location"
  32. exit
  33. fi
  34.  
  35. # Remove 'space', so filenames with spaces work well.
  36. IFS="`$Printf '\n\t'`"
  37.  
  38. # Take all filenames and write in name.txt
  39. $Ls -1 > .name.txt
  40. FILE=.name.txt
  41.  
  42. # Create text info dialog with filenames.
  43. # Here you can edit the filenames.
  44. # And save as name.txt.edit
  45. $Zenity --text-info --editable \
  46. --width $WINDOW_WIDTH --height $WINDOW_HEIGHT \
  47. --title="$WINDOW_TITLE" \
  48. --filename=$FILE > $FILE.edit
  49.  
  50. # Create a question dialog if you want rename the files.
  51. $Zenity --question --width $WINDOW_WIDTH --title="$WINDOW_TITLE" \
  52. --text="Do you want to rename the files?"
  53.  
  54. # Start rename the files.
  55. if [[ $? == 0 ]] ; then
  56. a=1
  57. for i in `$Ls`
  58. do
  59. Line=$($Sed -ne "$a p" $FILE.edit)
  60. echo $Line
  61. $Mv -n $i $Line
  62. a=$[$a + 1]
  63.  
  64. done
  65. else
  66.  
  67. # If user abort stop everything remove all files
  68. # created by the script and then exit.
  69. $Rm -rf $FILE $FILE.edit
  70. exit
  71. fi
  72.  
  73. # Remove all files created by the script
  74. $Rm -rf $FILE $FILE.edit
  75.  
  76. # Notify when all finish and then exit.
  77. $Notify "$WINDOW_TITLE" \
  78. "All files renamed."
  79.  
  80. exit

Κωνσταντινε ειδα το Creative Commons αλλα δεν καταλαβα πως το σκριπτακι θα ειναι κατω απο αυτη την αδεια? Τι και πως θα το κανω δηλαδη?

Body Mind Spirit

Μη σε παραπλανησω, δε τα εχω ψαξει καλ αυτα με τις αδειες περα απο το blogging.
Λιγο υπομονη εχουμε εξπερ στο θεμα να μας πουν

Αρκεί απλά να βάλεις ένα copyright (2010) πάνω-πάνω με το ονοματεπώνυμο σου, κ από κάτω να βάλεις ένα κείμενο που να υποδεικνύει την ακριβή άδεια με την οποία διανέμεις τον κώδικα σου.

Πχ, για να σε ξανα-ματα-παραπέμψω στο g-man, εγώ επέλεξα GPL v3 άδεια, κ έβαλα το ακόλουθο πάνω-πάνω στο script, μετά την περιγραφή του τί κάνει κ πριν αρχίσει ο κώδικας:

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.

Το οποίο κ πήρα από τη σελίδα του GNU foundation.

Ακολουθούν μερικά χρήσιμα links για να σε βοηθήοουν να διαλέξεις, κ υπόσχομαι σύντομα άρθρο που να εξηγεί τί παίζει με τις ανοιχτές άδειες, ομοιότητες, διαφορές, κλπ κλπ

http://www.gnu.org/copyleft/gpl.html
http://www.gnu.org/copyleft/lesser.html
http://en.wikipedia.org/wiki/BSD_licenses
http://en.wikipedia.org/wiki/MIT_License
http://creativecommons.org/about/licenses

Συνέχισε πάντως, πολύ καλή προσπάθεια!

-- gnu_labis

Το Linux ΔΕΝ είναι Windows!!!

Ευχαριστω gnu_labis το g-man θυμηθηκα και εγω και το σκριπτακι εγινε ετσι:

  1. #!/bin/bash
  2.  
  3. # S.S.Re (simply smart renamer) a simple tool to rename multiple files.
  4. # This tool is a graphical fronted which uses Zenity and basic command
  5. # line tools to rename multiple files.
  6. # You must have zenity in your system.
  7. # Author: TROiKAS [email protected]
  8.  
  9. # (C) Copyright 2010 Dimitris Aggeloudas
  10. #
  11. # This program is free software: you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation, either version 3 of the License, or
  14. # (at your option) any later version.
  15. #
  16. # This program is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU General Public License for more details.
  20. #
  21. # You should have received a copy of the GNU General Public License
  22. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  23.  
  24. # To begin with, set the app title and version
  25. TITLE="S.S.Re"
  26. VERSION="1.0"
  27.  
  28. # Set window title and window width
  29. WINDOW_TITLE=$TITLE" (v"$VERSION")"
  30. WINDOW_WIDTH=325
  31. WINDOW_HEIGHT=500
  32.  
  33. # Paths to needed executables. Please adjust as necessary
  34. Zenity=/usr/bin/zenity
  35. Printf=/usr/bin/printf
  36. Ls=/bin/ls
  37. Sed=/bin/sed
  38. Mv=/bin/mv
  39. Rm=/bin/rm
  40. Notify=/usr/bin/notify-send
  41.  
  42. # Check if Zenity can be found. If not, produce error message
  43. # (with "xmessage", since zenity is not available) and bail out
  44. if [ ! -e "$Zenity" ]; then
  45. xmessage "ERROR: $Zenity not found. You must install the Zenity\
  46. package, or provide an alternative location"
  47. exit
  48. fi
  49.  
  50. # Remove 'space', so filenames with spaces work well.
  51. IFS="`$Printf '\n\t'`"
  52.  
  53. # Take all filenames and write in name.txt
  54. $Ls -1 > .name.txt
  55. FILE=.name.txt
  56.  
  57. # Create text info dialog with filenames.
  58. # Here you can edit the filenames.
  59. # And save as name.txt.edit
  60. $Zenity --text-info --editable \
  61. --width $WINDOW_WIDTH --height $WINDOW_HEIGHT \
  62. --title="$WINDOW_TITLE" \
  63. --filename=$FILE > $FILE.edit
  64.  
  65. # Create a question dialog if you want rename the files.
  66. $Zenity --question --width $WINDOW_WIDTH --title="$WINDOW_TITLE" \
  67. --text="Do you want to rename the files?"
  68.  
  69. # Start rename the files.
  70. if [[ $? == 0 ]] ; then
  71. a=1
  72. for i in `$Ls`
  73. do
  74. Line=$($Sed -ne "$a p" $FILE.edit)
  75. echo $Line
  76. $Mv -n $i $Line
  77. a=$[$a + 1]
  78.  
  79. done
  80. else
  81.  
  82. # If user abort stop everything remove all files
  83. # created by the script and then exit.
  84. $Rm -rf $FILE $FILE.edit
  85. exit
  86. fi
  87.  
  88. # Remove all files created by the script
  89. $Rm -rf $FILE $FILE.edit
  90.  
  91. # Notify when all finish and then exit.
  92. $Notify "$WINDOW_TITLE" \
  93. "All files renamed."
  94.  
  95. exit

Ευχαριστω για την βοηθεια, καθε μερα μαθαινω και κατι καινουργιο.

Body Mind Spirit

Ασχετο σχετικό.

Ενδιαφέρομαι να βάλω αυτή την άδεια σε κάποια scriptάκια δικά μου.

Πρέπει να "επικοινωνήσω" με κάποιον, να δηλώσω οτι "θέλω να βάλω την άδεια" κ.λ.π. κ.λ.π. ή με ένα απλό copy paste της άδειας είμαι εντάξει;

Εδώ http://www.gnu.org/licenses/gpl.html λέει οτι το δεύτερο αρκεί αλλά μήπως πρέπει να προσέξω καλύτερα;

troikas]

Ενα μεγαλο ευχριστω στον Constantino που για μια φορα ακομη ανεβασε δουλεια μου στο Blog του YAGLB S.S.Re

Body Mind Spirit

 

Κι από μένα, επίσης. Είναι πράγματι ένα blog που αξίζει! :)

------------------------------------------------------------------------------------

"Όταν βλέπεις τον πιγκουίνο, ξέρεις τι πρέπει να κάνεις": ΒΑΖΕΙΣ LINUX!

Αποστόλης]

Ασχετο σχετικό.

Ενδιαφέρομαι να βάλω αυτή την άδεια σε κάποια scriptάκια δικά μου.

Πρέπει να "επικοινωνήσω" με κάποιον, να δηλώσω οτι "θέλω να βάλω την άδεια" κ.λ.π. κ.λ.π. ή με ένα απλό copy paste της άδειας είμαι εντάξει;

Εδώ http://www.gnu.org/licenses/gpl.html λέει οτι το δεύτερο αρκεί αλλά μήπως πρέπει να προσέξω καλύτερα;

Απ'οτι καταλαβα μαλλον αρκει το copy paste.

Body Mind Spirit

 

Μπορεί κάποιος να μου εξήγησει τι λέει ακριβώς αυτό το σχόλιο?
http://gnome-look.org/content/show.php/S.S.Re+%28Simply+Smart+Renamer%29?content=132341
Πάνω κάτω κατάλαβα το νόημα (δεν είναι κάτι καλό παντως).

 

Body Mind Spirit

 Α καλα μην ασχολεισαι και πολυ.

Εχει κανει και ο τυπος ενα αντιστοιχο σκρπτ που μετονομαζει φακελους και σου δινει συμβουλες και καλα, οτι δε το εχεις ονομασει σωστα το σκριπ σου.

Εγω μια χαρα ειδα να τα εχεις ολα....

Constantinos]

 Α καλα μην ασχολεισαι και πολυ.

Εχει κανει και ο τυπος ενα αντιστοιχο σκρπτ που μετονομαζει φακελους και σου δινει συμβουλες και καλα, οτι δε το εχεις ονομασει σωστα το σκριπ σου.

Εγω μια χαρα ειδα να τα εχεις ολα....

Ευχαριστω Κωνσταντινε.

Body Mind Spirit