Sponsored Content
Top Forums Shell Programming and Scripting Script For Folder Management Automation Post 302591220 by traustic on Thursday 19th of January 2012 10:56:44 PM
Old 01-19-2012
Thanks for responding.
=====================
these are duplicates:

Code:
banana-1-16-2012 banana-1-16-2012===========================
Those were a mistake - all folder names are different, beginning is the same and the date is different for all.

Basically I save images of live systems and name them:
Apple-date-i-made-image
Banana-date-i-made-image
Crape-date-i-made-image

Over time I create:
apple-date-i-made-image 4-5 times with different dates but same beginning.
banana-date-i-made-image 6 times with different dates but same beginning.
crape-date-i-made-image 3 times with different dates but same beginning.

I'm going to distribute this cloner configuration to coworkers and need something that cleans up extra images they aren't using. So a max of 2 images with the same 'intro name' exist on the usb. Apple only works on machine 1, Banana works on machine 2, and Crape works on machine 3 and they are not interchangeable.

---------- Post updated 01-19-12 at 09:39 PM ---------- Previous update was 01-18-12 at 10:56 PM ----------

any ideas?

Want to keep two images available on usb for each of three systems.

Windows XP image
Windows 7 image
Windows NT Server image

All three computers contain different hardware settings and want to keep the two latest and delete the rest.

---------- Post updated at 11:56 PM ---------- Previous update was at 09:39 PM ----------

Found something:

Code:
#!/bin/bash
# edit above line to the path to bash
#command to find is: "which bash"
#
##############set your variables below###########
# prefix is the prefix of the filename,
# example filename: server1-07-20-2011.bak, the prefix would be: server1
# numtokeep is the number of backups you would like to preserve
# backupFolder is the location of your backup files, exclude trailing slash
#
prefix=poop
numtokeep=3
backupFolder=/home/dustin/test
#################################################
#
#  go to backup folder just to be safe
cd $backupFolder
#
# count how many files are in backup folder, and set to a variable
filecount=`ls -l $backupFolder/$prefix* | wc -l`
#
# checking to see if number of backups is greater than number to keep
if [ $filecount -gt $numtokeep ]
        then
                extras=$(($filecount - $numtokeep))
                echo "leaving $numtokeep, deleting $extras"
                for counter in $(ls -ltr $backupFolder/$prefix* |  head -n $extras | awk '{ print $8 }')
                do
                        if [ "$1" == "--test" ]
                        then
                                echo "Will delete: $counter"
                        else
                                echo "deleting: $counter"
                                rm -R $counter
                                if [ $? != 0 ] ; then
                                echo "Error deleting: $counter"
                                else
                                echo "Successfully deleted: $counter"
                                fi
                        fi
                done
        else
                echo "not enough backups to delete"
fi


from:
dustinmihalko.com/2011/07/bash-script-to-delete-old-files-leaving-last-few/

Last edited by Franklin52; 01-20-2012 at 03:11 AM.. Reason: Please use code tags for code and data samples, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script for Finding files in a folder and copying to another folder

Hi all, I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt. I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Discussion started by: satish2712
5 Replies

2. Shell Programming and Scripting

FTP automation script

Hi, I have got a requirement like this. a parameterized function custFtp which will take 5 i/ps and will do the following tasks. p1) server name p2) username p3) password p4) path name of the server where the file resides p5) file name pattern the function will work like this. ... (1 Reply)
Discussion started by: ani_datta
1 Replies

3. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

4. Shell Programming and Scripting

Help with Shell Script automation

can someone look into this one please... I am struck at this point. I do not know what logic to be followed here. I can go ahead with my work only, if this step is done. Please Help. I have a process X in a shell script. Once the process X is done, it generates a log file. Process X is basically... (1 Reply)
Discussion started by: ss3944
1 Replies

5. Shell Programming and Scripting

Script Automation

Hi Gurus, I have a clearcase script that i use to check in a single file at time on my clearcase server. the script is as follows setmyview settask 75098_MSI_TRILOGY_EIM cd /vobs/Trilogy_R12/custom/msieim/12.0.0/sql/ cleartool co -nc . ct mkelem -nc Filename_1.sql cp... (3 Replies)
Discussion started by: r_t_1601
3 Replies

6. Shell Programming and Scripting

Script to move one folder to multiple folder...

Hi All, I have to requirement to write a shell script to move file from one folder (A) to another five folder (B,C,D,E,F) and destination folder should be blank. In not blank just skip. This script will run as a scheduler every 2 minutes. It will check number of files in folder A and move 1 to... (9 Replies)
Discussion started by: peekuabc
9 Replies

7. Shell Programming and Scripting

awk script automation

I have the below code which calculates the time difference between src and dst from a large trace file. The code works for a given source and destination. However, I want to automate the code to go over any src and destination. The format of the source is like that: X.Y where x is always =2 and Y... (10 Replies)
Discussion started by: ENG_MOHD
10 Replies

8. Shell Programming and Scripting

Automation script

Hello All , I came across a tricky solution to devolop . Here is a part of the requirement automation . I have different set of server say : Web ( has 4 servers under it ) , App ( has 4 servers under it ) , DB ( has 2 servers under it ) Above each i have different load balancers , Say : Web... (4 Replies)
Discussion started by: radha254
4 Replies

9. Shell Programming and Scripting

Automation Script for Oracle

Hi, As a Oracle Developer, I am writing many Procedures,Functions and Packages. Facing Many optimization issue after writing these Database objects. Trying to tune it manually. Can we write any Shell/Perl/Python script to Optimize these Database objects instead of doing manual check and... (1 Reply)
Discussion started by: vasuvv
1 Replies

10. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies
image(n)						       Tk Built-In Commands							  image(n)

__________________________________________________________________________________________________________________________________________________

NAME
image - Create and manipulate images SYNOPSIS
image option ?arg arg ...? _________________________________________________________________ DESCRIPTION
The image command is used to create, delete, and query images. It can take several different forms, depending on the option argument. The legal forms are: image create type ?name? ?option value ...? Creates a new image and returns its name. type specifies the type of the image, which must be one of the types currently defined (e.g., bitmap). name specifies the name for the image; if it is omitted then Tk picks a name of the form imagex, where x is an integer. There may be any number of option-value pairs, which provide configuration options for the new image. The legal set of options is defined separately for each image type; see below for details on the options for built-in image types. If an image already exists by the given name then it is replaced with the new image and any instances of that image will redisplay with the new contents. It is important to note that the image command will silently overwrite any procedure that may currently be defined by the given name, so choose the name wisely. It is recommended to use a separate namespace for image names (e.g., ::img::logo, ::img::large). image delete ?name name ...? Deletes each of the named images and returns an empty string. If there are instances of the images displayed in widgets, the images won't actually be deleted until all of the instances are released. However, the association between the instances and the image manager will be dropped. Existing instances will retain their sizes but redisplay as empty areas. If a deleted image is recreated with another call to image create, the existing instances will use the new image. image height name Returns a decimal string giving the height of image name in pixels. image names Returns a list containing the names of all existing images. image type name Returns the type of image name (the value of the type argument to image create when the image was created). image types Returns a list whose elements are all of the valid image types (i.e., all of the values that may be supplied for the type argument to image create). image width name Returns a decimal string giving the width of image name in pixels. BUILT-IN IMAGE TYPES The following image types are defined by Tk so they will be available in any Tk application. Individual applications or extensions may define additional types. bitmap Each pixel in the image displays a foreground color, a background color, or nothing. See the bitmap manual entry for more informa- tion. photo Displays a variety of full-color images, using dithering to approximate colors on displays with limited color capabilities. See the photo manual entry for more information. KEYWORDS
height, image, types of images, width Tk 4.0 image(n)
All times are GMT -4. The time now is 04:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy