import os import shutil # Define the folder path from which you want to extract files folder_path = 'satellite_images/masked' texts_to_match = [1677843764871,1684906005406,1711771596326,1704953689234,1709112826214,1675930368286,1675747639165,1676529494047,1675054638861,1674629069526,1697515942343,1677665562738,1623990371841,1614579162993,1711713693259,1711798669281,1706340026114,1711603544575,1674794172481,1709615178320,1675481880024,1620102006840,1674457829808,1675930428752,1689750218000,1704954332838,1676357661070,1676455038371,1624337464217,1698477661861,1674456394378,1677910583988,1678426503365,1677646753707,1678169101192,1711686349604,1676095946695,1674629223576,1680327064249,1675481909438,1675744640742,1698477535095,1711688973281,1675747575351,1624096601707,1675747545618,1679892592254,1620038422842,1706173823085,1712900326332,1623821893983,1675398835486,1706350943763,1674557499228,1710919159704,1676436015494,1676375580938,1677652990725,1679634096255,1674625533569,1706173722030,1698477724887,1612353226144,1676618786988,1709621726387,1675223820647,1711713032207,1619519554786,1678445520558,1674457900066,1622177416320,1614314470271,1675149928792,1709620810441,1676093735499,1675766059453,1674628320425,1677909230671,1613640910659,1623670935331,1706175868852,1675840764514,1674558979647,1675837674913,1679985025197,1675848746059,1621059106121,1676540557804,1711369423787,1675842457910,1675062598568,1710310381634,1676268891495,1675746007914,1674618672073,1676626395452,1620454101777,1675746231658,1621341576991,1674556714579,1675839940318,1704955191338,1675925848998,1615178902732,1634023060224,1679719544770,1674555752170,1615191174854,1709115688227,1624086026096,1674542255365,1698477864925,1624946648432,1710992467778,1676548991266,1706174255381,1706593836110,1708931074513,1624946583018,1676700538018,1620637948533,1674622819992,1675916372996,1623999903851,1620618958178,1674453763129,1620024159554,1674558702651,1675417173426,1613453157589,1674626378375,1676372975925,1679912306701,1675228535566,1680007595908,1617167339494,1676441994286,1620280203004,1711714425137,1677579792470,1697085850854,1711430647243,1676094573014,1676894572235,1676272594904,1623988824959,1679649496512,1675241090206,1674468439450,1620025682628,1676352170947,1675339606540,1674542734127,1674629515258,1680259627904,1676098323887,1615030731869,1676528803487,1675312718688,1679652285332,1681358815997,1675311795585,1623989466232,1674640307040,1704951451879,1674620189301,1711610001836,1711800593771,1674717384892,1620194717564,1675928146269,1698309800838,1674625338857,1709121255076,1674622373482,1674537418190,1632293938417,1677731384815,1678429118089,1615192747627,1709552031344,1674456563517,1676530832424,1677818261257,1675417039686,1674624497279,1676351247568,1614577366524,1676544613420,1679906149329,1619500938783,1675422928971,1678429034195,1675224727849,1711684765958,1709620422182,1679119398861,1674534521117,1621320010391,1676452597859,1675490755975,1619849980789,1675220484498,1620385508962,1676542220696,1711369305879,1679914796437,1625037557139,1614579476137,1674283633299,1675220563464,1679906376753,1679905693207,1620637421398,1704950561904,1675482006632,1704953955804,1679739115382,1706176217830,1676371561876,1623827642493,1711370184421,1613636619565,1674625047722,1623830302778,1679629034573,1676530897694,1674555700477,1674550571858,1621244972079,1675485672917,1677666749912,1675223834393,1675335655367,1674620610163,1697775617823,1706593177187,1675220357644,1620025317173,1675417713285,1704950009400,1674625737459,1712901236980,1677842159483,1706178576145,1676618710251,1621056385602,1706339260041,1679119328563,1674122916161,1710308461442,1677909055219,1711079326004,1624422286585,1709192664298,1710995598958,1674556381989,1705649756185,1676547032607,1674454039870,1674451029905,1679912476852,1697174465181,1615026944399,1674458246095,1675747415774,1675425044781,1675417393984,1620885897648,1699936617201,1711778968300,1706503689413,1675483876531,1711773545359,1675750800840,1709353705555,1676699965306,1698310775400,1677911310714,1621056234249,1675229629741,1619500468175,1709012903661,1622184146481,1676631836184,1710917367034,1680327130575,1704955807576,1711773245238,1704954375290,1676540385678,1629353796130,1675922406397,1710991669818,1624683097492,1614582069777,1623821222024,1679650088035,1676696699456,1624077591530,1676545610254,1676455168243,1709113158169,1675928000546,1620901166273,1676542746210,1709623084453,1674460338744,1676705121917,1674298280476,1615011150978,1697089251161,1674633092249,1676371256187,1679902378274,1709104369331,1676094169209,1699590204644,1674557397052,1675853550684,1678426563659,1679903761289,1675417205828,1620453783131,1679903522631,1674556546711,1674453649889,1620718022468,1674455894269,1617168585510,1615184397859,1706175671026,1676352236019,1617102252735,1712901559975,1620636609857,1675747390846,1711608885409,1675748448549,1709641116635,1676271262977,1674458440186,1674458602465,1679113798470,1676624975894,1706593237845,1706175296906,1680587211148,1706352007812,1712899787390,1617100309833,1710926257048,1675483839667,1674626391774,1676274686842,1709621621734,1613191644200,1675926385007,1676539595326,1675745614476,1689750138616,1711776546030,1675140322032,1697713423842,1615195465782,1679901793497,1675929584271,1676620038108,1619844151113,1677575064823,1675424527906,1676702324246,1708149872067,1615029642032,1711797760617,1706347016103,1674635452230,1709551438201,1679891317410,1713248342397,1680256684771,1675315039902,1622186074119,1710567805181,1676369968894,1704951541349,1674556456494,1712900535997,1619669691205,1674625093841,1615179472385,1675337376774,1674647400242,1623831836487,1622171671464,1704981305369,1619850698009,1675417358658,1675937124045,1698923762011,1706351717727,1674633395731,1674559685878,1678082332855,1704954121848,1675399183023,1677577928634,1711772831433,1706339650706,1623988155613,1674546418728,1674625138598,1679898427493,1675746280703,1701495567030,1678253877410,1675922346109,1675766885365,1676544165596,1712143023826,1710998188893,1619520037984,1675747451159,1674562522189,1679911787702,1675487678735,1675223887830,1619676098625,1678426657032,1675916374275,1620364582528,1615026038216,1674123877808,1679718596398,1674629173980,1709615000244,1679398806045,1674453716233,1678260690130,1675936405016,1614577997473,1619499495858,1711352020225,1674451400309,1674622418197,1676354893992,1704961298315,1676632091110,1674796773221,1676355236536,1709627834013,1704950063081,1679650208876,1674620669078,1712030299367,1674624433957,1708930447044,1620215085271,1675312667956,1675929002078,1679914655421,1706348650089,1675230640982,1679119110732,1676539767824,1674457778626,1705736811055,1704950908472,1709274134907,1674453428989,1704955289800,1675492947696,1704955398157,1701079271295,1711077686470,1709011711477,1711715069976,1709192401905,1700206868900,1698482712217,1620799431076,1676547093233,1674453590344,1704950228737,1707106593326,1676356359025,1675416970489,1679549843812,1697089730853,1620277942697,1711369263635,1619850332067,1678426600984,1621056340729,1674627985796,1674626660916,1711347607544,1679911992317,1704954997310,1678172060534,1634023236202,1674623363252,1674544810467,1677580196219,1706174875851,1615030898369,1623494394676,1674554640299,1711799573140,1676542888757,1706609979101,1677817402254,1710310752374,1677652443079,1620275490133,1619500915072,1679915561608,1676538195671,1711609139170,1632293847690,1674623187408,1675832412507,1709641478381,1676269163263,1619587863808,1676542975491,1614576734885,1704953774426,1675484055265,1674622138623,1674453531475,1706349701364,1706173529522,1706348886315,1676624881939,1706352297160,1684905003178,1706176052007,1627469496215,1679739555633,1701079589593,1697786790228,1676095590436,1711449127902,1706537501014,1682673383086,1676975599618,1706177930709,1620804233719,1678942943226,1675492728198,1614079737274,1710995473466,1678255979453,1680326970543,1615191753184,1674634329820,1711369286499,1675315469543,1676703743218,1676106157047,1675335605692] print(len(texts_to_match)) texts_to_match = [str(num) for num in texts_to_match] #print(texts_to_match) # Destination folder where matched files will be moved destination_folder = 'masked_filter' # Iterate through all files in the folder for filename in os.listdir(folder_path): # Check if any of the texts_to_match are in the filename #print(filename) if any(text in filename for text in texts_to_match): # Construct full path to the file source_file = os.path.join(folder_path, filename) # Move the file to the destination folder shutil.move(source_file, destination_folder) print(f'Moved {filename} to {destination_folder}')