15,796,299 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Python questions
View PHP questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by build56 (Top 16 by date)
build56
9-Aug-22 5:00am
View
Okay done all of the above and gave 100 stars ha ha ha ha ha
Thank you
build56
9-Aug-22 4:58am
View
Sorry Richard I had already posted that befor you got back to me explaining it.
SORRY
build56
8-Aug-22 12:57pm
View
Well thank you VERY VERY much, it nice to goto a site and not to be ask Read the book, are you dum etc etc.
We all have to start some where and this IS A VERY good site .
I will when I get a bit more experance on python BUT I will keep logging in and if I can help Anyone I will
Just one last thing Can I save or copy these text from you and me?
Just in case I for get somthing
MANY MANY thanks
Kind Regards
build56
8-Aug-22 12:47pm
View
Okay all done and working
PLEASE how can I pay you for ALL YOUR TIME?
build56
8-Aug-22 12:37pm
View
WORKS GREAT
if I put in
py richard.py c:\
scans all drive c:\ and puts in the folder "build"in the Root of c:\ with all jpg files no problem
BUT if I put in
py richard.py c:\fred
It moves all jpg into c:\fred\build with all jpgs
That is no problem becaue I can look in there any way.
GREAT GREAT
But if a did just want to copy rarther the move is that a simple alteration in the scrip
I MUST thank you very much for all your time with me.
Is there anyway I can pay you for you time PLEASE
build56
8-Aug-22 11:47am
View
oh okay will give that a Try
Did it make the folder "build"
Thank you
build56
8-Aug-22 11:43am
View
Thank you for your help with this
BUT i'm no ay nearer to my problem then when I started on here.
Just such little thing to search on a folder onl and not all of hard rive.
Been to the Python web site BUT coul dbot see any person who could sort it for a fee.
Notto worry will just have to keep looking and trying to sort out why it is not working
Thank you
build56
8-Aug-22 11:18am
View
the main code works all fine and does fined the jpg above 10k BUT it only copies then and not MOVE them also It scanes ALL the hard drive.
I thought it would be simply just to change that line of code to not to search in c:\\ BUT search in c:\fred or what ever. ha ha ha So I thought
build56
8-Aug-22 11:13am
View
is there any where I can go and get this sorted?
I have only just started on python and do not know how to check what is what.
I would be willing to pay a small fee to ge tthis sorted
build56
8-Aug-22 9:23am
View
arrrrrrrrrrrrrrr I have found out that the jpg.py must be in the director/folder where I running the command prompt from. BUT the code does not run because it does not make the "directory = "buiild"" or move any of the jpg files Hmmmmm I'm getting more and more confused
build56
8-Aug-22 9:13am
View
i have put that file in that folder and still get the error
build56
8-Aug-22 9:09am
View
Why is it searching in the c:\users\test directory ? when from the command prompt I put c:\test
build56
8-Aug-22 6:56am
View
Thank you for getting back to me and spending so much of your time.
I have done this
code
===========================
import shutil
import re
import win32api
import glob
import sys
from PIL import Image
import PIL
from pathlib import Path
#%%
def find_file(root_folder, rex):
for root,dirs,files in os.walk(root_folder):
for filename in glob.glob(root+"/*.jpg", recursive=True):
try:
if os.stat(filename).st_size>12000:
result=filename#
print('Screenshot found')
directory = "buiild"
parent_directory= str(root_folder)
destination = os.path.join(parent_directory, directory)
source=os.path.join(root,filename)
print(source)
try:
os.makedirs(destination, exist_ok = True)
shutil.move(source,destination)
except OSError as error:
pass
else:
break
except PIL.UnidentifiedImageError:
pass
#%%
#drive=win32api.GetLogicalDriveStrings().split('\000')[:-1] ## to select the drive
#if drive[0]=='C:\test': # change here
# find_file(drive[0],re)
import sys
# Program begins here
search_path = 'C:\\' # default search path
if len(sys.argv) > 1:
search_path = sys.argv[1] # get the path name from the command line
==================================================
I run it like
py jpgtest.py c:\test
BUT I get a error like
======================
C:\Users\test>py jpgtest.py c:\test
C:\Users\test\AppData\Local\Programs\Python\Python310\python.exe: can't open file 'C:\\Users\\test\\jpgtest.py': [Errno 2] No such file or directory
==========================
Why is it searching in the USER folder and NOT what I put on the commaned line LIKE c:\test
Sorry for being so dum, BUT I am a Blond ha ha ha
build56
7-Aug-22 15:41pm
View
Hmmmm "program starts"
I thought from the above code that I pasted it would start at the top of the code from
import os
Or have I got that wrong
build56
7-Aug-22 14:13pm
View
so do i paste your bit of code below the #% thentake out the other code about c drive etc?
build56
7-Aug-22 10:25am
View
Sorry for my mistake in reply to this problem, did look for the reply but missed it.
Any way
problem I have a code in python that do this
1 look in the c drive then look in all folders
2 look for all jpg files bigger than 10kbytes (file Size)
3 move to a folder on d: drive called buiild
all works fine as is BUT
I want to be able to change from searching ALL folders to a folder called test or a folder that I can put in the code like c:\test here is the code
=================================
import os
import shutil
import re
import win32api
import glob
from PIL import Image
import PIL
from pathlib import Path
#%%
def find_file(root_folder, rex):
for root,dirs,files in os.walk(root_folder):
for filename in glob.glob(root+"/*.jpg", recursive=True):
try:
if os.stat(filename).st_size>10000:
result=filename#
print('Screenshot found')
directory = "buiild"
parent_directory= str(root_folder)
destination = os.path.join(parent_directory, directory)
source=os.path.join(root,filename)
print(source)
try:
os.makedirs(destination, exist_ok = True)
shutil.move(source,destination)
except OSError as error:
pass
else:
break
except PIL.UnidentifiedImageError:
pass
#%%
drive=win32api.GetLogicalDriveStrings().split('\000')[:-1] ## to select the drive
if drive[0]=='C:\\': # change here
find_file(drive[0],re)
=======================================
If you look at the line where it says
if drive[0]=='C:\\': # change here
I want to change that to something like
if drive[0]=='C:\\test': # change here
BUT IT DOES NTO WORK
Hope I have giving you more information this time
Thank you for you time
Show More