Sponsored Content
Top Forums Shell Programming and Scripting zsh compare size pdf and delete bigger? Post 302537861 by rdcwayx on Sunday 10th of July 2011 08:16:19 PM
Old 07-10-2011
confirm you can get the size by command : stat -c %s yourfile, otherwise, replace by :

Code:
ls -l $pdf | awk '{ print $5}'

Code:
for pdf in *.pdf
do
   Spdf=$( stat -c %s $pdf)
   xpdf=${pdf/.pdf}.xpdf
   if [ -f $xpdf ] ; then
      Sxpdf=$( stat -c %s $xpdf)
   else
      echo "$xpdf is not exist"
      exit
   fi
   
   # delete the bigger one 
   if [ "$Spdf" -gt "$Sxpdf" ]; then
      rm $xpdf
   else
      mv $xpdf $pdf
   fi
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to compare file size after ftp?

Is possible if I want to campare file size on source and destination after ftp transfer? If anybody know, please explain to me. (1 Reply)
Discussion started by: icemania
1 Replies

2. Shell Programming and Scripting

how can i print the output of the shell script in bigger size

how can i print the output of the shell script in bigger size eg: echo " hello world" i want to print this in the output with bigger size in the middle of the screen. can someone please help me out in that (2 Replies)
Discussion started by: mail2sant
2 Replies

3. Shell Programming and Scripting

sort files by date, delete oldest, if total size bigger than

hello people i need your help please i want to achieve the following with the simplest, most efficient shell-tools: i have a directory with a lot of files from users. the script should check which partition the dir is on if the partition with the directory is more than 90% full ... (2 Replies)
Discussion started by: scarfake
2 Replies

4. Shell Programming and Scripting

Checking files size and deleting if bigger than x

Hello , I have to write a crontab line make a check on a file and, if bigger than 2Gb, to stop apache daemon, delete the file and restart apache . Someone have suggestions ? Thanks (2 Replies)
Discussion started by: gogol_bordello
2 Replies

5. Shell Programming and Scripting

Delete all lines that start with a bigger number of a specific one.

E.g. the file is like this: I want to delete all lines that begin with a number larger than 2, ignoring the lines that doesn't begin with a number! PS:'2' is actually a variable that can have a lot of values:b:i bet you got it (10 Replies)
Discussion started by: hakermania
10 Replies

6. Shell Programming and Scripting

reduce pdf file size through multiple folders

Dear all, i have a lot of .pdf files that i need to reduce size with pdf2ps and ps2pdf app. I need a script which i can reduce file size of all .pdf files in every subfolder of WORKDIR folder. folder tree like: WORKDIR SUBBWORK DIR1 SUB_SUB_WORKDIR1 ... (1 Reply)
Discussion started by: migor78
1 Replies

7. Shell Programming and Scripting

compare between files size

Hello i have file A created yesterday and file B created today thanks to help create script compare between 2 files according to size so if file B is less than 10% of file A i should have echo message with warning also check if file B exist or not. this should be run in loop for list of... (6 Replies)
Discussion started by: mogabr
6 Replies

8. Shell Programming and Scripting

How to delete some of the files in the directory, if the directory size limits the specified size

To find the whole size of a particular directory i use "du -sk /dirname".. but after finding the direcory's size how do i make conditions like if the size of the dir is more than 1 GB i hav to delete some of the files inside the dir (0 Replies)
Discussion started by: shaal89
0 Replies

9. Shell Programming and Scripting

Script to Compare file size and delete the smaller

I am pretty new to scripting, so I appreciate your advice in advance. The problem: 100 directories each containing 2 files that have the same extension with random names. The only attribute that discriminates the files is size. I would like to write a script that compares the files for size... (6 Replies)
Discussion started by: JC_1
6 Replies

10. Shell Programming and Scripting

Compare fields and keep record with bigger ID?

How do you write a shell script to compare records with the same fields then keep the biggeer id number fields (field separate by a pipe) 1150| San Jose|8|15|7|2013-02-19 00:00:00.000|2013-02-20 00:00:00.000 1263|San Jose|8|15|7|2013-02-19 00:00:00.000|2013-02-20 00:00:00.000... (4 Replies)
Discussion started by: sabercats
4 Replies
gpdf(1) 							   User Commands							   gpdf(1)

NAME
gpdf - view PDF documents SYNOPSIS
gpdf [gnome-std-options] [filename...] DESCRIPTION
The PDF Document Viewer application is based on xpdf. PDF Document Viewer provides viewing features such as panning, zoom in, zoom out, best fit, and fit width. OPTIONS
The following options are supported: gnome-std-options Standard options available for use with most GNOME applications. See gnome-std-options(5) for more information. OPERANDS
The following operands are supported: filename The name of the to be . EXAMPLES
Example 1: Launching the PDF Document Viewer example% gpdf Example 2: Opening the Document test.pdf in PDF Document Viewer example% gpdf test.pdf ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of gpdf: NLSPATH. EXIT STATUS
The following exit values are returned: 0 Application exited successfully >0 Application exited with failure FILES
The following files are used by this application: /usr/bin/gpdf Executable for PDF Document Viewer. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-* | +-----------------------------+-----------------------------+ |Interface stability |External | +-----------------------------+-----------------------------+ SEE ALSO
PDF Document Viewer Manual Latest version of the GNOME Desktop User Guide for your platform. gnome-std-options(5) NOTES
Written by Niall Power, Sun Microsystems Inc., 2003. SunOS 5.10 1 Oct 2003 gpdf(1)
All times are GMT -4. The time now is 10:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy