Script To dlete PDF file s and Folders


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script To dlete PDF file s and Folders
# 1  
Old 04-29-2005
Script To dlete PDF file s and Folders

Hi

We have to delete PDF files and Folders older than five days .Can anyone help with the shell script

Regards
Ved
# 2  
Old 04-29-2005
Quote:
Originally Posted by ved123
Hi

We have to delete PDF files and Folders older than five days .Can anyone help with the shell script

Regards
Ved
check this:

Code:
find <directory> -name "*.[pPdDfF]" -ctime +5 -exec rm {} \;

where <directory> is the directory structure that the pdf's are in. the funkiness in " " just checks for any combination of upper-case and lower-case p d f. the only part i'm not 100% on is the -ctime, whether it should be -mtime or not
# 3  
Old 04-29-2005
"*.[pPdDfF]" should be "*.[pP][dD][fF]"
I have not tried the script myself
# 4  
Old 04-29-2005
Quote:
Originally Posted by sssow
"*.[pPdDfF]" should be "*.[pP][dD][fF]"
I have not tried the script myself
Hi

But i am new to shell scripting.How do you give the path here.I mean can you please help me with complete script.

Regards
# 5  
Old 05-02-2005
Quote:
Originally Posted by ved123
Hi

But i am new to shell scripting.How do you give the path here.I mean can you please help me with complete script.

Regards
you already have the complete script ... just put in the correct directory name where <directory> is ... here's chuckuykendalls's code with sssow's modification ...
Code:
find <directory> -name "*.[pP][dD][fF]" -ctime +5 -exec rm {} \;

# 6  
Old 05-02-2005
Hi guys

even though i am new i tried to put like this

Is this correct

#!/bin/sh
echo "Removing tmp directories and PDF files older than 5 days created by users"
#!/bin/sh
cd /opt/dctm/....Path
echo 'Current Direcotory is' $PWD

"find ./ -name '*.pdf' -mtime +5 >>test.out"

find ./ -type d -mtime +5 -exec rm -R {} \;

find ./ -name '*.pdf' -exec rm '{}' ';'

"find ./ -name '*.pdf' -mtime +5 >>test1.out"

diff test.out,test1.out >> test2.out

mailx -s" Deleted Files For $TODAY at $TIME" xyz.com <test2.out

I am trying to delete folders and pdf files in temp and trying to write before and after and comparing to get deleted files and mailing them.
# 7  
Old 05-02-2005
Code:
find ./ -name '*.pdf' -exec rm {} \;

"find ./ -name '*.pdf' -mtime +5 >>test1.out"

your code as written will not do what you want as it removes ALL the ".pdf" files before listing those ".pdf" files that are older than 5 days --- your listing will always come out clean since you don't have any ".pdf" files to list ...

btw, i suggest you keep to the same programming style throughout your script --- makes it easier to debug that way ... and don't put your command line in double quotes as the shell will most likely not run it ...
Code:
find ./ -type d -mtime +5 -exec rm -R {} \;

find ./ -name '*.pdf' -exec rm '{}' ';'

find ./ -name '*.pdf' -mtime +5 >>test1.out

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to compare files in 2 folders and delete the large file

Hello, my first thread here. I've been searching and fiddling around for about a week and I cannot find a solution.:confused: I have been converting all of my home videos to HEVC and sometimes the files end up smaller and sometimes they don't. I am currently comparing all the video files... (5 Replies)
Discussion started by: Josh52180
5 Replies

2. Shell Programming and Scripting

Shell Script for enter folders and join file

Hello everyone. I have a dlink cam that save recordings splitted for hours. Each hour folder contain a lot of small avi files. Repository has the following directories structure: \_20140101/ \_ 01 \_a.avi \_b.avi \_ 02 \_c.avi ... (3 Replies)
Discussion started by: setterx
3 Replies

3. Shell Programming and Scripting

Converting secured pdf files to pdf using acroread

Does anybody have idea of Converting secured pdf files to pdf using acroread ? ---------- Post updated at 04:49 PM ---------- Previous update was at 04:44 PM ---------- This file is not password protected. (4 Replies)
Discussion started by: Soham
4 Replies

4. Shell Programming and Scripting

PDF Script to extract PDF Links MOD in Need

In here we have a script to extract all pdf links from a single page.. any idea's in how make this read instead of a page a list of pages.. and extract all pdf links ? #!/bin/bash # NAME: pdflinkextractor # AUTHOR: Glutanimate (http://askubuntu.com/users/81372/), 2013 #... (1 Reply)
Discussion started by: danielldf
1 Replies

5. Shell Programming and Scripting

Convert excel file to PDF file using shell script

Hi All, Is it possible to convert the excel file to PDF file(Without loosing any format) using unix shell scripting ??? If yes Kindly help me on the code Thanks in advance!!! (5 Replies)
Discussion started by: Balasankar
5 Replies

6. Shell Programming and Scripting

Shell Script to Dynamically Extract file content based on Parameters from a pdf file

Hi Guru's, I am new to shell scripting. I have a unique requirement: The system generates a single pdf(/tmp/ABC.pdf) file with Invoices for Multiple Customers, the format is something like this: Page1 >> Customer 1 >>Invoice1 + invoice 2 >> Page1 end Page2 >> Customer 2 >>Invoice 3 + Invoice 4... (3 Replies)
Discussion started by: DIps
3 Replies

7. UNIX for Dummies Questions & Answers

Remove file and folders Script

Hi I am trying to modify a script that will remove files and folders under a set directory on my server. I am using the following find /home/test/HM/ -type d -exec rm -rf {} \; 2>/dev/null This removes the files in the HM folder but it also removes the HM folder which i do not want to... (3 Replies)
Discussion started by: treds
3 Replies

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

9. Shell Programming and Scripting

Perl - Convert html to pdf - PDF::FromHTML

Hi, I am trying to convert html to pdf using perl module PDF::FromHTML, am getting the error as given below. not well-formed (invalid token) at line 2, column 17, byte 56 at C:/Perl/lib/XML/Parser.pm line 187 at C:/Perl/site/lib/PDF/FromHTML.pm line 140 The perl code is as given... (2 Replies)
Discussion started by: DILEEP410
2 Replies

10. Shell Programming and Scripting

Shell script to check if any file exists in 4 folders

Hi All, working on AIX 5.3. Requirement is: Shell script in ksh to check if any file exists in 4 folders as below: 1. /FILE/INB/INT1 2. /FILE/INB/INT2 3. /FILE/INB/INT3 4. /FILE/INB/INT4 Thanks a lot for your time! a1_win. (3 Replies)
Discussion started by: a1_win
3 Replies
Login or Register to Ask a Question