Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index International Gentoo Users Forum italiano (Italian) Risorse italiane (documentazione e tools)
  • Search

[TOOL] Eliminare quello che si ha su CD...

Forum riservato alla documentazione in italiano.

Moderator: ago

Post Reply
  • Print view
Advanced search
4 posts • Page 1 of 1
Author
Message
_sys/sid
Guru
Guru
User avatar
Posts: 346
Joined: Fri Aug 27, 2004 5:07 pm
Location: Asola (Mantova)
Contact:
Contact _sys/sid
Website

[TOOL] Eliminare quello che si ha su CD...

  • Quote

Post by _sys/sid » Sun Dec 05, 2004 5:47 pm

Ho fatto un piccolo script in python (per me' molto utile) che elimina da una cartella quello che e' contenuto in un altra cartella.

In Parlole un po' piu' chiare.
- Mi Copio su CD un po' di file della dir distfiles
- Elimino tutti i file che ho messo su cd con questo script.

Ecco qui il Programma.
Selezionate, Incollate nel vostro editor preferito e salvatelo da qualche parte.
magari in una directory Eseguibile come '/usr/bin'

pkgrm 0.1

Code: Select all

#!/usr/bin/env python

import sys
import os

def main(path1, path2):
	try:
		dir1 = os.listdir(path1)
	except OSError, msg:
		print msg
		sys.exit(0)
	try:
		dir2 = os.listdir(path2)
	except OSError, msg:
		print msg
		sys.exit(0)
	
	for pkg1 in dir1: 
		for pkg2 in dir2:
			if (pkg1 == pkg2): 
				print "Remove", pkg1, "=", pkg2
				try:
					os.remove(path1 + "/" + pkg1)
				except OSError, msg:
					print msg
					
	

if (__name__ == '__main__'):
	if (len(sys.argv) < 3):
		print "Usage:"
		print "   pkgrm [ dir1 ] [ dir2 ]"
		print
		print "Example:"
		print "   pkgrm /usr/portage/distfiles /mnt/dvdrom/distfiles"
		print
	else:
		print "Path1:", sys.argv[1]
		print "Path2:", sys.argv[2]
		main(sys.argv[1], sys.argv[2])
	sys.exit(0)
Per Eseguire il Programma
Salvatelo 'magari come' pkgrm e poi fatelo partire indicando 2 directory:

Code: Select all

Usage:
   pkgrm [ dir1 ] [ dir2 ]

Example:
   pkgrm /usr/portage/distfiles /mnt/dvdrom/distfiles
ATTENZIONE - Il Programma elimina senza chiedere conferma.
Quindi attenti a quello che fate!
http://th30z.netsons.org/
Top
Panda
Apprentice
Apprentice
User avatar
Posts: 223
Joined: Thu Jul 31, 2003 1:05 pm
Location: Cremona <=> Catania
Contact:
Contact Panda
Website

  • Quote

Post by Panda » Sun Dec 05, 2004 10:33 pm

sai che e' interessante?

Io lo perferzionerei in stile etc-update... nel senso che potresti implementare un resoconto delle differenze delle due locazioni, far decidere file per file, oppure segare via tutto quello che non e' sul cd...
Top
fedeliallalinea
Administrator
Administrator
User avatar
Posts: 31978
Joined: Sat Mar 08, 2003 11:15 pm
Location: here
Contact:
Contact fedeliallalinea
Website

  • Quote

Post by fedeliallalinea » Wed Dec 08, 2004 4:09 pm

Aggiunto ai post utilissimi sezione tools
Questions are guaranteed in life; Answers aren't.

"Those who would give up essential liberty to purchase a little temporary safety,
deserve neither liberty nor safety."
- Ben Franklin
https://www.news.admin.ch/it/nsb?id=103968
Top
oRDeX
Veteran
Veteran
User avatar
Posts: 1325
Joined: Sun Oct 19, 2003 12:08 pm
Location: Italy
Contact:
Contact oRDeX
Website

  • Quote

Post by oRDeX » Wed Dec 08, 2004 4:25 pm

Magari proprio come etc-update potresti implementare un menù che mette in evidenza tutti i file che vorrebbe rimuovere con le varie opzioni, se cancellarli tutti senza guardarli, se cancellarli uno per uno con conferma, o selezionando il file da cancellare
Top
Post Reply
  • Print view

4 posts • Page 1 of 1

Return to “Risorse italiane (documentazione e tools)”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy