Home: Perl Programming Help: Beginner:
Read from .txt, find in folder then delete



forro
New User

Oct 26, 2012, 12:44 AM


Views: 1672
Read from .txt, find in folder then delete

Hello all,

I am trying to ease my work by creating a script to do what I manually do every week:

I have a .txt file with .png file names:
230.png
34.png
.
.

I would like to read the txt file (solved) then to search the files on my system (for eg. "/pictures/new/"), extract the file path (for eg. "/pictures/new/230.png") and then to delete those results / files.

It would help me a lot to solve this.

I am 1/4 through the Begginer's Lama book so I need some help with this to reach the deadline.

Thank you,


wickedxter
User

Oct 26, 2012, 2:21 AM


Views: 1670
Re: [forro] Read from .txt, find in folder then delete

open file

#use this only if the file is small less than 100mb
@file =file handle; this sulrps the hole file

open dir
@dir = readdirr;

loop file
loop dir
setup some matches

.........ect


Laurent_R
Veteran / Moderator

Oct 26, 2012, 3:00 AM


Views: 1664
Re: [forro] Read from .txt, find in folder then delete

Hi,

take a look at the folowwing module: File::Find.

It parses directory trees to look for files. This will probably do what you need.


forro
New User

Oct 26, 2012, 3:26 AM


Views: 1663
Re: [Laurent_R] Read from .txt, find in folder then delete

Thank you all,

I will try this tonight and if I get stuck I will come back with some code sample to find the error(s).